THpubs
THpubs

Reputation: 8172

In Rails Devise gem how to modify the send_reset_password_instructions method?

I want to modify the send_reset_password_instructions method so that I can send some extra parameters through it to the url. Then I can read that parameter in the url and if its present I will style the view (and the mailer) in a different way.

What I really need to do is send the reset password instead of confirmation email. I have already made my app send the reset password instead of confirmation but now I need to edit the mailer and the view to be different. How can I do this?

Upvotes: 1

Views: 3087

Answers (1)

Justin Ho Tuan Duong
Justin Ho Tuan Duong

Reputation: 606

OK so your question has 2 parts.

  • Overriding the send_reset_password_instructions method:

    1. Visit the Devise Github page and find where the method is defined.
    2. Create a file with the same name and relative path in you own app folder. Eg.: Devise has this helper app/mailers/devise/mailer.rb, if you want to override it you create the same in you own app directory.
    3. Copy the method and override as needed. Devise will automatically pickup the files.
  • Editing the views / mailers: You just need to run this command:

    rails generate devise:views

You will have the mailer views in you views folder.

Hope this helps :)

Upvotes: 6

Related Questions