我在为我的应用程序设置重定向时遇到问题。用户应该转到他们的个人资料(用户/节目),管理员应该转到管理仪表板。我该如何设置?
目前出现以下错误:
NameError in ActiveAdmin::Devise::SessionsController#create
undefined local variable or method `admin' for #<ActiveAdmin::Devise::SessionsController:0x007febe12667e8>
应用控制器
def after_sign_in_path_for(resource_or_scope)
if admin
redirect_to admin_dashboard_path
else
@user
end
end
end
你没有admin
要访问变量,您需要检查给定的参数是什么。
def after_sign_in_path_for(resource)
stored_location_for(resource) ||
if resource.is_a?(Admin)
admin_dashboard_path
else
user_path(resource)
end
end
你也应该not在此方法内重定向,它应该只返回设计可以使用的路径。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)