简体   繁体   English

用户编辑密码后,Rails Devise重定向

[英]Rails Devise redirect after User edits their password

I am trying to change the path after the user changes his password following the guide on the devise documentation: Customize-the-redirect-after-a-user-edits-their-profile 用户尝试根据设计文档上的指南更改密码后,尝试更改路径: 自定义重定向后的用户编辑其配置文件

Right now, I know that I have to create my own RegistrationController like 现在,我知道我必须创建自己的RegistrationController

class RegistrationsController < Devise::RegistrationsController
  protected
  def after_update_path_for(resource)
    user_path(resource)
  end
end

and change the path to 并将路径更改为

def after_update_path_for(resource)
  dashboard_path
end

I created the Registration Model with 我创建了注册模型

rails g controller Registrations  

and moved it to the app/controllers folder 并将其移至app / controllers文件夹

Now it says that I should also configure the routes like 现在它说我也应该配置路由

devise_for :users, :controllers => { :registrations => :registrations }

I am not really familiar with writing routes like that since I only use resources:, so i tried 我不太喜欢这样编写路由,因为我仅使用资源:,所以我尝试了

devise_for :users, :controllers => { :registrations => 'dashboard#show' }

which gave me the error: 这给了我错误:

'dashboards#show' is not a supported controller name. This can lead to potential routing problems.

I don't quite know how I should write the routes correctly in order to change the path to dashboard_path. 我不太清楚如何正确编写路由才能将路径更改为dashboard_path。

Do I even generate my controller correctly? 我什至可以正确生成控制器吗?

You can use redirect_to root_path and define the root in your ~/config/routes.rb. 您可以使用redirect_to root_path并在〜/ config / routes.rb中定义根。

You can define the root path by typing root 'dashboard#show' (or more conventionally) root 'dashboard#index' . 您可以通过键入root 'dashboard#show' (或更传统地) root 'dashboard#index'来定义根路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM