通过 Devise 输入并发送密码说明电子邮件后,我想重定向到主页(根)页面,而不是默认登录页面。根据 SO 上的说明,我编辑了 passwords_controller.rb 如下:
class Users::PasswordsController < Devise::PasswordsController
protected
def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
root_path
end
end
我的路线.rb:
devise_for :users
devise_scope :user do
authenticated :user do
root 'places#route', as: :authenticated_root
unauthenticated do
root 'places#index', as: :unauthenticated_root
end
end
来自上方的带有“路线”的位置控制器:
def route
path = case current_user.memberships.exists?
when false
pages_path
else
page_path(current_user.memberships.where(page_id: @page))
end
redirect_to path
end
我做错了什么?我真的很感激。