ruby-on-rails – 我正在使用Devise,密码更改是重定向到主页,如何保持/ users / edit?

栏目: Ruby · 发布时间: 6年前

内容简介:翻译自: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?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

复杂网络理论及其应用

复杂网络理论及其应用

汪小帆、李翔、陈关荣 / 清华大学出版社 / 2006 / 45.00元

国内首部复杂网络专著 【图书目录】 第1章 引论 1.1 引言 1.2 复杂网络研究简史 1.3 基本概念 1.4 本书内容简介 参考文献 第2章 网络拓扑基本模型及其性质 2.1 引言 2.2 规则网络 2.3 随机图 2.4 小世界网络模型 2.5 无标度网络模型 ......一起来看看 《复杂网络理论及其应用》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具