Change devise_invitable themes

by default, the theme for the invitation is

mailer: invitation_instructions: subject: 'Invitation instructions' 

I would like to change it to

 subject: '%{invited_by} has invited you!' 

but this requires the invite_by variable, available for the translation method for i18n.

How can I get this variable available / declared without changing the default behavior too much?

+8
ruby-on-rails rails-i18n devise actionmailer devise-invitable
source share
1 answer

There will be no default email program for you, but it’s pretty easy to set up a custom email program and define your own subject_for helper there:

 # 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 
+27
source share

All Articles