문제

I have a user model with rolify gem. In my app I am using active_admin as admin interface. Have can I restrict active_admin to admin users only?

도움이 되었습니까?

해결책

Try putting your rolify role check in the same place as mentioned in the Active Admin documentation's example for getting access to the current user:

class OnlyAdmins < ActiveAdmin::AuthorizationAdapter
  def authorized?(action, subject = nil)
    # Do rolify check here
    user.has_role? :admin
  end
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top