How can I get devise invitable to use a different devise mailer I set in the config file?
In devise invitable, the invite! method does the following:
def invite!
if new_record? || invited?
self.skip_confirmation! if self.new_开发者_运维技巧record? && self.respond_to?(:skip_confirmation!)
generate_invitation_token if self.invitation_token.nil?
self.invitation_sent_at = Time.now.utc
save(:validate => false)
::Devise.mailer.invitation_instructions(self).deliver
end
end
However, because I wanted devise to use PostageApp, I created a new mailer called new_devise_mailer.rb which is basically the same as devise mailer, but inherits PostageApp.
In the config/initialization/devise.rb file, I set config.mailer = "NewDeviseMailer" instead of "Devise:Mailer"
How can the invitable module know to use the new mailer?
The invitable module should automatically use NewDeviseMailer
since it calls Devise.mailer
, not Devise::Mailer
and you changed the default mailer in the initializer.
精彩评论