Skip to content

Commit 4a73cf0

Browse files
committed
Add Welcome email for new subscribers
1 parent 4a0ce5d commit 4a73cf0

File tree

13 files changed

+82
-5
lines changed

13 files changed

+82
-5
lines changed

app/controllers/users/confirmations_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def update
5353
if @user.confirm!
5454
warden.set_user(@user, scope: :user)
5555

56+
WelcomeNotifier.deliver_to(@user)
57+
5658
redirect_to users_dashboard_path, notice: "Thank you for confirming your email address"
5759
else
5860
redirect_to new_users_confirmation_path, alert: "Something went wrong"

app/mailers/emails/user_mailer.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ def password_reset(user, password_reset_token)
1919

2020
mail to: @user.email, subject: "Reset your password"
2121
end
22+
23+
def welcome(user)
24+
@user = user
25+
26+
mail to: @user.email, subject: "Welcome to Joy of Rails!"
27+
end
2228
end

app/notifiers/welcome_notifier.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class WelcomeNotifier < NotificationEvent
2+
def self.deliver_to(user, **)
3+
new(params: {user: user}).deliver(user, **)
4+
end
5+
6+
def deliver_notification(notification)
7+
user = notification.recipient
8+
9+
Emails::UserMailer.welcome(user).deliver_later
10+
end
11+
end

app/views/emails/magic_session_mailer/no_account_found.text.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Is this the right email?
1+
# Is this the right email?
22

33
It looks like there isn’t an account on test tied to this email address.
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Sign in to Joy of Rails
1+
# Sign in to Joy of Rails
22

33
Follow this link to sign in: <%= users_magic_session_token_url(@magic_session_token) %>

app/views/emails/user_mailer/confirmation.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>Welcome to Joy of Rails!</h1>
1+
<h1>Complete your Joy of Rails registration</h1>
22

33
<p>
44
<%= link_to "Confirm your email address", edit_users_confirmation_url(@confirmation_token) %>.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Welcome to Joy of Rails!
1+
# Complete your Joy of Rails registration
22

33
Follow this link to confirm your email address: <%= edit_users_confirmation_url(@confirmation_token) %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Password reset for Joy of Rails
1+
# Password reset for Joy of Rails
22

33
Follow this link to reset your password: <%= edit_users_password_url(@password_reset_token) %>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<p>Thank you for signing up for the Joy of Rails newsletter! I am humbled to have you here :)</p>
2+
3+
<p>As you might have guessed, things are just getting underway at Joy of Rails. You’re one of the first to join and I’m grateful for that. I’m excited to see where this journey takes us. Tell your friends and colleagues and spread the Joy of Rails. The more the merrier!</p>
4+
5+
<p>Now that you’ve joined, you can expect occasional email updates from me. I’ll do my best to send you interesting and engaging Ruby on Rails content that’s worth your attention and time. Maybe every, now and then, something to put a smile on your face.</p>
6+
7+
<p>If you’re into RSS, you may want to subscribe to the <%= link_to "Joy of Rails feed", feed_index_url %>.</p>
8+
9+
<p>You can also <%= link_to "unsubscribe", unsubscribe_users_newsletter_subscriptions_url %> at any time. That’s ok too!</p>
10+
11+
<p>If you have any questions, feedback, or just want to say hi, please don’t hesitate to reach out. I’d love to hear from you.</p>
12+
13+
<p>- Ross</p>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Thank you for signing up for the Joy of Rails newsletter! I am humbled to have you here :)
2+
3+
As you might have guessed, things are just getting underway at Joy of Rails. You’re one of the first to join and I’m grateful for that. I’m excited to see where this journey takes us. Tell your friends and colleagues about Joy of Rails. The more the merrier!
4+
5+
Now that you’ve joined, you can expect occasional email updates from me. I’m going to do my best to send you interesting and engaging Ruby on Rails content that’s worth your attention and time. Maybe every, now and then, something to put a smile on your face.
6+
7+
If you’re into RSS, you may want to subscribe to the Joy of Rails feed: <%= feed_index_url %>.
8+
9+
You can also unsubscribe at any time: <%= unsubscribe_users_newsletter_subscriptions_url %>. That’s ok too!
10+
11+
If you have any questions, feedback, or just want to say hi, please don’t hesitate to reach out. I’d love to hear from you.
12+
13+
- Ross

0 commit comments

Comments
 (0)