Skip to content

How To: Redirect URL after sending reset password instructions

Kim Røen edited this page Jan 4, 2019 · 4 revisions

Source: http://stackoverflow.com/questions/8809681/cannot-override-devise-passwords-controller

Look at the source code for devise's PasswordsController:

respond_with resource, location: after_resetting_password_path_for(resource)

You'll have to create a PasswordsController in your app that inherits from Devise::PasswordsController, implement only the after_sending_reset_password_instructions_path_for(resource_name) method and when setting the routes tell devise to use your controller.

class PasswordsController < Devise::PasswordsController
  protected
  def after_sending_reset_password_instructions_path_for(resource_name)
    #return your path
  end
end

Remember to update your routes.rb-file to use this custom controller:

devise_for :users, controllers: { passwords: 'passwords' }
Clone this wiki locally