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

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

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

查看所有标签

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

深入理解Nginx

深入理解Nginx

陶辉 / 机械工业出版社 / 2013-4-15 / 89.00元

本书是阿里巴巴资深Nginx技术专家呕心沥血之作,是作者多年的经验结晶,也是目前市场上唯一一本通过还原Nginx设计思想,剖析Nginx架构来帮助读者快速高效开发HTTP模块的图书。 本书首先通过介绍官方Nginx的基本用法和配置规则,帮助读者了解一般Nginx模块的用法,然后重点介绍如何开发HTTP模块(含HTTP过滤模块)来得到定制的Nginx,其中包括开发一个功能复杂的模块所需要了解的......一起来看看 《深入理解Nginx》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

SHA 加密
SHA 加密

SHA 加密工具