问题描述
我目前正在使用 Rails 进行该项目。 我想在 sign_out 时更改重定向,但在我的网站上,每个 sign_out 都使用下面的代码重定向到同一页面。 我想知道如何让它与众不同。
请告诉我。 谢谢。
在 application.controller 上
def after_sign_out_path_for(resource_or_scope)
if resource_or_scope == :user ←this works
new_user_session_path
elsif resource_or_scope == :admin ←this doesn't work.
new_admin_session_path
else
user_root_path
end
end
解决方法
感谢好心人的评论,我意识到我必须知道我必须知道使用哪种型号的设备,我找到了Staff型号,所以我将其更改如下。 我解决了它。谢谢。
def after_sign_out_path_for(resource_or_scope)
if resource_or_scope == :user
user_root_path
elsif resource_or_scope == :staff ←this doesn't work.
admin_root_path
end
end