Reputation: 653
I want to customize devise confirmation mail subject with dynamic content.
I have tried to achieve that by using this link.
There is no change. It is taking the "Confirmation Instructions" string from devise.en.yml. then I have changed in devise.en.yml file. It has been reflected but anyway It is static change. But I need to change the subject with dynmaic content.
Please guide me to fix this issue.
Upvotes: 3
Views: 754
Reputation: 653
I fixed this issue by creating a subclass of Devise::Mailer
class DeviseMailer < Devise::Mailer
def reset_password_instructions(record, token, opts={})
mail = super
# custom logic
mail.subject = "[Dynamic Subject]"
mail
end
end
and customized devise.rb in initializer to call the custom emailer
config.mailer = 'DeviseMailer'
Upvotes: 4