How To Change The Subject Of A Devise Email

Posted by Weston Ganger on August 02, 2016

Sometimes you may want to change the subject of a devise email. This also works with devise_invitable. Its pretty simple.

First tell devise we want to use a custom controller:

# config/initializers/devise.rb
config.mailer = "CustomDeviseMailer"

Then create the custom devise mailer. In this example I am overriding the devise_invitable invitation_instructions email:

# app/mailers/custom_devise_mailer.rb:
class CustomDeviseMailer < Devise::Mailer

  def subject_for(key)
    if key.to_s == 'invitation_instructions'  
      "You have been invited to Super Awesome App"
      return super

Related External Links:

Posted in Rails and Tagged with devise devise_invitable 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts