2011-03-10 37 views
3

我試圖做Use custom route upon model validation failureDevise,我沒有任何運氣。有設計失敗的驗證保持在同一個URL?

我有這樣的規定我的路線:

# authentication routing 
devise_for :users do 
    get "/login" => "devise/sessions#new" 
    get "/logout" => "devise/sessions#destroy" 
    get "/register" => "devise/registrations#new" 
end 

但在驗證失敗時,說/register頁面,網址變回/users

當驗證失敗時,我希望URL保持在/register。我將如何做到這一點?

+0

因此,我基本上遇到了同樣的問題,並得到了相同的解決方案。此解決方案的問題在於設置「after_sign_up_path_for(resource)」不再有效。你有沒有遇到同樣的問題,你知道答案嗎? – kindofgreat 2012-10-20 03:10:03

回答

4

球。在我發佈之後,我再次想到 - 你不知道嗎? - 閱讀。在How to change the login and signup urls in devise plugin Rails3https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes

尋找一遍,我現在有這樣的:

# authentication routing 
devise_for :users, :controllers => { :sessions => 'devise/sessions' }, :skip => [:sessions] do 
    get "/login" => "devise/sessions#new", :as => :new_user_session 
    post "/login" => "devise/sessions#create", :as => :user_session 
    get "/logout" => "devise/sessions#destroy", :as => :destroy_user_session 
    get "/register" => "devise/registrations#new", :as => :new_user_registration 
    post "/register" => "devise/registrations#create", :as => :user_registration 
end 

出現按預期運行。

+0

編輯:這工作完全謝謝。任何想法如何讓這個工作在一個組合的登錄/註冊頁面? – jackocnr 2012-11-02 16:37:45