2012-01-14 49 views
1

我遇到的問題似乎是Devise的authenticate _#{role}!方法劫持我的註冊嘗試。authenticate_user!劫持註冊/創建方法

Started GET "/client/sign_up" for 127.0.0.1 at 2012-01-14 12:02:52 +0000 
    Processing by Client::RegistrationsController#new as HTML 
Rendered /Users/robertwwhite/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.5.3/app/views/devise/shared/_links.erb (1.4ms) 
Rendered client/registrations/new.html.haml within layouts/application (97.6ms) 
Rendered client/_navigation.html.haml (1.6ms) 
Rendered shared/_flash_messages.html.haml (0.1ms) 
Completed 200 OK in 126ms (Views: 116.4ms | ActiveRecord: 7.2ms) 

Started POST "/client" for 127.0.0.1 at 2012-01-14 12:02:58 +0000 
    Processing by WishesController#index as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"vq3wgsQeb4eoxhb3sw2Q2kd4edIoOxIfrzJ/WzJUAn0=", "client"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"} 
Completed 401 Unauthorized in 13ms 

Started GET "/client/sign_in" for 127.0.0.1 at 2012-01-14 12:02:58 +0000 
    Processing by Client::SessionsController#new as HTML 
Rendered /Users/robertwwhite/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.5.3/app/views/devise/shared/_links.erb (1.0ms) 
Rendered client/sessions/new.html.haml within layouts/application (16.5ms) 
Rendered client/_navigation.html.haml (1.5ms) 
Rendered shared/_flash_messages.html.haml (0.3ms) 
Completed 200 OK in 60ms (Views: 38.6ms | ActiveRecord: 6.4ms) 

我試過覆蓋after_signup_path_for(resource_or_scope),但它似乎被忽略。

# app/controllers/application_controller.rb 
def after_sign_up_path_for(resource_or_scope) 
    random_path 
end 

因此,用戶無法首先在網站上註冊。有任何想法嗎?

回答

2

你是否檢查過你的路線是否覆蓋了默認的設計路線/方法?

與類似問題的用戶的清晰度編輯由哈爾:

我在我的config/routes.rb中我上面的方法devise_for以下。

match "client" => "wishes#index" 

這是壓倒一切的設計的

devise_for :clients, :path => :client 

通過以下移動它,它給制定優先級,並且還通過GET請求到合適的控制器和動作不劫持POST請求。