将Devise失败的验证保留在同一个URL上吗?

时间:2011-03-10 21:44:40

标签: ruby-on-rails-3 devise

我正在尝试Use custom route upon model validation failureDevise这样做,我没有运气。

我的路线指定如下:

# 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。我该怎么做?

1 个答案:

答案 0 :(得分: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

这似乎按预期工作。