我正在尝试Use custom route upon model validation failure和Devise这样做,我没有运气。
我的路线指定如下:
# authentication routing
devise_for :users do
get "/login" => "devise/sessions#new"
get "/logout" => "devise/sessions#destroy"
get "/register" => "devise/registrations#new"
end
但是当验证失败时,请在/register
页面上说明,网址会更改回/users
。
我希望在验证失败时网址保持在/register
。我该怎么做?
答案 0 :(得分:4)
球。我再一次在发布之后想出来 - 你不知道吗? - 阅读。
再次关注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
这似乎按预期工作。