feat(mailers): add NotificationMailer, new_post
This commit is contained in:
1 parent
2226e46cd6
commit
4015436e50
2 files changed
+58
No files matched your search
@@ -0,0 +1,34 @@
|
||||
class NotificationMailer < Prism::Mailer::Base
|
||||
self.template_roots = [File.join(APP_ROOT, 'app', 'views', 'mailers')]
|
||||
default from: 'blog@prism.example'
|
||||
|
||||
def new_post(post_id)
|
||||
@post = Post.find(post_id)
|
||||
@post_url = "/posts/#{@post.to_param}"
|
||||
mail(to: 'editors@prism.example', subject: "New post: #{@post.title}")
|
||||
end
|
||||
|
||||
def welcome(user_id)
|
||||
@user = User.find(user_id)
|
||||
mail(to: @user.email, subject: 'Welcome to Prism Blog')
|
||||
end
|
||||
|
||||
# `token` is generated by the caller (User#generate_token_for(:password_reset),
|
||||
# see PasswordResetsController#create) rather than here - keeps this
|
||||
# mailer, like the others, a pure "given the data, render+send" step with
|
||||
# no signing concerns of its own.
|
||||
def password_reset(user_id, token)
|
||||
@user = User.find(user_id)
|
||||
@reset_url = url_for(:edit_password_reset, token: token)
|
||||
mail(to: @user.email, subject: 'Reset your Prism Blog password')
|
||||
end
|
||||
|
||||
# `token` is generated by the caller, same reasoning as password_reset
|
||||
# above - either User's own after_commit(on: :create) at signup time, or
|
||||
# EmailConfirmationsController#create for a resend.
|
||||
def confirmation_instructions(user_id, token)
|
||||
@user = User.find(user_id)
|
||||
@confirmation_url = url_for(:email_confirmation, token: token)
|
||||
mail(to: @user.email, subject: 'Confirm your Prism Blog email address')
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user