有设计失败的验证保持在同一个URL?
问题描述:
我试图做Use custom route upon model validation failure与Devise,我没有任何运气。有设计失败的验证保持在同一个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
。我将如何做到这一点?
答
球。在我发布之后,我再次想到 - 你不知道吗? - 阅读。在How to change the login and signup urls in devise plugin Rails3和https://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
因此,我基本上遇到了同样的问题,并得到了相同的解决方案。此解决方案的问题在于设置“after_sign_up_path_for(resource)”不再有效。你有没有遇到同样的问题,你知道答案吗? – kindofgreat 2012-10-20 03:10:03