Skip to content

Instantly share code, notes, and snippets.

@lalitlogical
Last active March 21, 2017 07:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lalitlogical/fda5148411402efe35bd79917fcdb079 to your computer and use it in GitHub Desktop.
Save lalitlogical/fda5148411402efe35bd79917fcdb079 to your computer and use it in GitHub Desktop.
Dynamic subject for Devise mailers (i.e. reset_password_instructions)
class CustomDeviseMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views
def reset_password_instructions(record, token, opts={})
opts[:subject] = I18n.t(:'devise.mailer.reset_password_instructions.subject', app_name: ENV['APP_NAME'])
super
end
end
en:
devise:
.......
.......
mailer:
confirmation_instructions:
subject: "Confirmation instructions"
reset_password_instructions:
subject: "Reset your %{app_name} Password"
unlock_instructions:
subject: "Unlock instructions"
password_change:
subject: "Your %{app_name} Password Changed"
.......
.......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment