0
  1. Logged in user changes email under users#registration
  2. User receives email to confirm this email change

The email send in step 2 is exactly the same as when a user registers for the first time and has to confirm his email for the first time.

Is there a way to use another email view So I can more customise the text like "you requested your email to be changed, please click below link.. " instead of using the default message.

This would be a cosmetic but much wanted feature in our application.

Anyway to do this? Kind regards!

Rubytastic
  • 15,001
  • 18
  • 87
  • 175

1 Answers1

2

This is not trivial task, actualy you need to overwrite this devise method inside your model:

  def send_confirmation_instructions
    if reconfirmation_required?
      self.confirmation_token = nil if reconfirmation_required?
      @reconfirmation_required = false

      ensure_confirmation_token!

      opts = pending_reconfirmation? ? { :to => unconfirmed_email } : { }
      send_devise_notification(:reconfirmation_instructions, opts)
    else
      super
    end
  end

Then you need to extend Devise::Mailer to add method reconfirmation_instructions

And finally you need to create view app/views/devise/mailer/reconfirmation_instructions.html.erb

mikdiet
  • 9,859
  • 8
  • 59
  • 68
  • Great thank you for sharing. Is it possible to somehow extract all the "Devise specific" hacks from the user model to 1 central location to have things more organised? Answer accepted though its perfect – Rubytastic Jun 23 '13 at 11:39
  • Only getting a undefined method `ensure_confirmation_token!' for # – Rubytastic Jun 23 '13 at 11:43