Rails 4.1 Mailer Previews and Devise custom emails

For those looking to preview Devise emails without using custom mailers, (but still custom emails) this is what I did:

  1. Configure your app for email previewing.

  2. Set up the Devise Mailer Preview class

    a. Rails ~> 4.1

    # mailer/previews/devise_mailer_preview.rb
    class Devise::MailerPreview < ActionMailer::Preview
    
      def confirmation_instructions
        Devise::Mailer.confirmation_instructions(User.first, "faketoken")
      end
    
      def reset_password_instructions
        Devise::Mailer.reset_password_instructions(User.first, "faketoken")
      end
    
      ...
    
    end
    

    b. Rails ~> 5.0

    class DeviseMailerPreview < ActionMailer::Preview
    
      ... # same setup as Rails 4 above
    
  3. Restart the server

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)