Password Password Override

I want to disconnect

def create self.resource = resource_class.send_reset_password_instructions(resource_params) if successfully_sent?(resource) respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) else respond_with(resource) end end 

therefore it will not be redirected at all after sending the reset password

So, I created a new file under the application / controllers / users / called passwords_controller.rb

which is as follows

 class User::PasswordsController < Devise::PasswordsController def create self.resource = resource_class.send_reset_password_instructions(resource_params) if successfully_sent?(resource) flash[:notice] = "sent password" else respond_with(resource) end end def new super end def update super end def edit super end end 

and changed in my routes to

  devise_for :users, :controllers => { :invitations => 'users/invitations', :passwords => 'users/passwords' } 

I also have a devise_invite gem ..

When I click on the forgotten password link, I get this error

 Started GET "/users/password/new" for 127.0.0.1 at 2012-11-16 10:21:07 +0200 ActionController::RoutingError (uninitialized constant Users::PasswordsController): 

my rake routes

  user_password POST /users/password(.:format) users/passwords#create new_user_password GET /users/password/new(.:format) users/passwords#new edit_user_password GET /users/password/edit(.:format) users/passwords#edit PUT /users/password(.:format) users/passwords#update 

view link

 <%= link_to "Forgot your password?", new_password_path(User) , :class => "control-group", :style => "position: absolute; bottom: 0", :id=>"forgotpass" %> 

What am I missing?

+4
source share
2 answers

The password controller extends from the password controller. So, expand your password controller with password protection.

 class PasswordsController < Devise::PasswordsController ...................... end 

Change the routes for the password controller with

 devise_for :users, :controllers => { :passwords => "passwords" } 

and the routes will be like this: -

 user_password POST /password(.:format) Passwords#create new_user_password GET /password/new(.:format) Passwords#new edit_user_password GET /password/edit(.:format) Passwords#edit PUT /password(.:format) Passwords#update 
+9
source

If you want to keep the namespace, try:

 # routes.rb devise_for :users, controllers: { passwords: 'users/passwords' } # users/passwords_controller.rb class Users::PasswordsController < Devise::PasswordsController ... end 
+1
source

Source: https://habr.com/ru/post/1446396/


All Articles