具有CanCanAdapter的ActiveAdmin导致仪表板上的无限重定向 [英] ActiveAdmin with CanCanAdapter causing infinite redirect on dashboard
问题描述
在ActiveAdmin 0.6.0中使用CanCan适配器时。我有资源在工作,授权正在工作。但是,当我进入 / admin
的根ActiveAdmin页面时,它将重定向到 / admin
并永远继续下去。
When using the CanCan adapter in ActiveAdmin 0.6.0. I have a resource working and authorization is working. However, when I go to /admin
, the root ActiveAdmin page, it redirects to /admin
and continues this forever.
推荐答案
如果用户无权访问页面,则ActiveAdmin将重定向到仪表板。如果用户无权访问仪表板,则会导致无限重定向。
If the user does not have access to a page, ActiveAdmin redirects to the Dashboard. If the user doesn't have access to the dashboard, this results in an infinite redirect.
解决方案是使用户能够读取仪表板页面。将其放置在能力模型对象中:
Solution is to give the user the ability to read the dashboard page. Place this in the ability model object:
can :read, ActiveAdmin::Page, :name => "Dashboard"
在授权适配器文档,但无限重定向似乎是由ActiveAdmin中的错误。它既没有引发CanCan :: AccessDenied,也没有向用户显示消息。至少,它应该在开发中显示一条消息,以帮助解决此问题。但是目前还没有。
This is mentioned in the authorization adapter documentation, but the infinite redirect seems to be caused by a bug in ActiveAdmin. It is neither raising a CanCan::AccessDenied, nor displaying an message to the user. At the least, it should display a message in development to help troubleshoot this issue. But it does not currently.
这篇关于具有CanCanAdapter的ActiveAdmin导致仪表板上的无限重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!