gpt4 book ai didi

ruby-on-rails-3 - 设计失败的验证是否保留在相同的 URL 上?

转载 作者:行者123 更新时间:2023-12-01 13:02:15 25 4
gpt4 key购买 nike

我正在尝试这样做 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 页面上,URL 会变回 /users

我希望 URL 在验证失败时保留在 /register。我该怎么做?

最佳答案

球。我在发帖后的片刻又想通了——你不知道吗?——阅读。

查看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

这似乎按预期工作。

关于ruby-on-rails-3 - 设计失败的验证是否保留在相同的 URL 上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5266281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com