内容简介:翻译自:https://stackoverflow.com/questions/17816315/i-am-using-devise-the-password-change-is-redirecting-to-home-page-how-to-keep
我正在使用devise,视图文件是/devise/registrations/edit.html.erb(我没有对它进行任何更改):
<div><%= f.label :password %> <%= f.password_field :password, :autocomplete => "off" %></div> <div><%= f.label :password_confirmation %> <%= f.password_field :password_confirmation %></div> <% if f.object.encrypted_password.present? %> <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br /> <%= f.password_field :current_password %></div> <% end %> <div><%= f.submit "Update" %></div>
当用户更改密码时,他们将被重定向到root_url(主页).我想将它们保存在更改密码页面,即/ users / edit.我该怎么做?
编辑 – 我有编辑方法的registration_controller,我应该添加什么?
首先,OP在更改密码后有重定向问题,在设计中更改密码在RegistrationsController中,而PasswordsController用于“重置密码”. FYI @ amesee重置密码后重定向的答案.更改密码和重置密码是不同的
How To: Customize the redirect after a user edits their profile 并见 after_update_path_for(resource)
您应该在registrations_controller.rb上添加after_update_path_for(resource)方法,如下所示:
class RegistrationsController < Devise::RegistrationsController
protected
def after_update_path_for(resource)
root_path
end
end
翻译自:https://stackoverflow.com/questions/17816315/i-am-using-devise-the-password-change-is-redirecting-to-home-page-how-to-keep
以上所述就是小编给大家介绍的《ruby-on-rails – 我正在使用Devise,密码更改是重定向到主页,如何保持/ users / edit?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
构建高可用Linux服务器(第3版)
余洪春 / 机械工业出版社 / 2014-10 / 79.00元
《构建高可用Linux服务器(第3版)》是Linux运维领域公认的经典畅销书,是国内51CTO、IT168等知名网站和多位资深运维专家共同推荐的运维工程师必备的工具书! “酒哥”在Linux运维领域潜心实践近10年,一直在运维一线,技术和思维都紧跟时代的发展,非常清楚运维工程师们需要什么,应该学习什么。本书不仅是他近10年工作经验的结晶,同时也是他的数万名读者和数十万粉丝共同需求和集体智慧的......一起来看看 《构建高可用Linux服务器(第3版)》 这本书的介绍吧!