[英]Rails Devise redirect after User edits their password
用户尝试根据设计文档上的指南更改密码后,尝试更改路径: 自定义重定向后的用户编辑其配置文件
现在,我知道我必须创建自己的RegistrationController
class RegistrationsController < Devise::RegistrationsController
protected
def after_update_path_for(resource)
user_path(resource)
end
end
并将路径更改为
def after_update_path_for(resource)
dashboard_path
end
我创建了注册模型
rails g controller Registrations
并将其移至app / controllers文件夹
现在它说我也应该配置路由
devise_for :users, :controllers => { :registrations => :registrations }
我不太喜欢这样编写路由,因为我仅使用资源:,所以我尝试了
devise_for :users, :controllers => { :registrations => 'dashboard#show' }
这给了我错误:
'dashboards#show' is not a supported controller name. This can lead to potential routing problems.
我不太清楚如何正确编写路由才能将路径更改为dashboard_path。
我什至可以正确生成控制器吗?
您可以使用redirect_to root_path
并在〜/ config / routes.rb中定义根。
您可以通过键入root 'dashboard#show'
(或更传统地) root 'dashboard#index'
来定义根路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.