[英]Devise + Active Admin Redirect
我无法为我的应用程序设置重定向。 用户应该转到他们的个人资料(用户/节目),管理员应该去管理仪表板..我该如何设置?
目前收到以下错误:
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
你也应该不是这个方法里面重定向,它应该只返回设计可以使用路径。
if resource.class == User
root_path
elsif resource.class == AdminUser
admin_root_path
else
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.