2012-11-16 3 views
4

나는 그래서 그래서 다시 암호재정 고안 암호 컨트롤러

을 보낸 후 모든 리디렉션되지 않습니다

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 

을 사용하지 않으려는, I 앱/컨트롤러/사용자에 새 파일을 생성/이

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 

및 변경과 같은

passwords_controller.rb라고

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

나는 또한 devise_invite 보석이 내 경로 ..

나는이 오류를 얻을 잊어 버린 암호에 대한 링크를 클릭

Started GET "https://stackoverflow.com/users/password/new" for 127.0.0.1 at 2012-11-16 10:21:07 +0200 

ActionController::RoutingError (uninitialized constant Users::PasswordsController): 

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 

보기의 링크는

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

무엇이 누락 되었습니까?

+0

어쩌면 오타가 있기 때문에 – Thanh

+0

난 이해가 안 돼 –

+0

당신의보기에서'new_password_path (User)'를'new_user_password_path'로 바꾼다 – Thanh

답변

9

암호 컨트롤러는 암호 키 컨트롤러에서 확장되었습니다. 따라서, 암호 컨트롤러를 사용하여 암호 컨트롤러를 확장하십시오. 유증

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

및 경로와 암호 컨트롤러의 경로는 다음과 같이 될 것입니다

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

end 

변경 : - 네임 스페이스를 유지하려는 경우

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 
+1

' devise_for : users, : controllers => {: passwords => "passwords"}'소문자 "p"? –

+0

예,'{: passwords => "Password"}'는 작동하지 않았습니다. '{: passwords => "passwords"}'를 사용하십시오. –

1

, 시도 :

# routes.rb 
devise_for :users, controllers: { passwords: 'users/passwords' } 

# users/passwords_controller.rb 
class Users::PasswordsController < Devise::PasswordsController 
    ... 
end