How to get Active Admin to work with Pundit after login

谁说胖子不能爱 提交于 2019-12-01 06:07:06
user3787971

I found the answer!

After adding these two lines to the active admin initializer file

config.authorization_adapter = ActiveAdmin::PunditAdapter 

#this line sets the default policy to application_policy.rb
config.pundit_default_policy = "ApplicationPolicy"

I had to add this to dashboard.rb under app/admin/dashboard.rb

def index
  authorize :dashboards, :index?
end

Then I created a file in my policies folder called dashboard_policy.rb and added this code

class DashboardPolicy < ApplicationPolicy
   def dashboard?
   true
  end
  def index?
   true
  end
 end

That got it working!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!