on default, the subject for invitation mail is
mailer:
invitation_instructions:
subject: 'Invitation instructions'
I'd like to change it to
subject: '%{invited_by} has invited you!'
but this requires to have invited_by variable accessible to the translate method for i18n.
How can I have this variable accessible/declared without changing default behavior too much?
Devise default mailer won't work for you, but it's quite easy to set up a custom mailer and define there your own subject_for helper:
# in config/initializers/devise.rb:
...
config.mailer = "CustomDeviseMailer"
...
# in app/mailers/custom_devise_mailer.rb:
class CustomDeviseMailer < Devise::Mailer
protected
def subject_for(key)
return super unless key.to_s == 'invitation_instructions'
I18n.t('devise.mailer.invitation_instructions.subject',
:invited_by => resource.invited_by.try(:full_name) || 'Someone')
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With