开发者

How do I use the RailsAdmin.authorize_with method?

开发者 https://www.devze.com 2023-02-15 08:22 出处:网络
I installed the ra开发者_开发问答ils admin gem, and have it working with Devise easily enough. I want to authorize the user via a boolean value, since not all users are admin. Though I\'m not sure whe

I installed the ra开发者_开发问答ils admin gem, and have it working with Devise easily enough. I want to authorize the user via a boolean value, since not all users are admin. Though I'm not sure where to place the code or how it's supposed to work. i took the code from the readme, and have this currently:

RailsAdmin.authenticate_with do
  redirect_to root_path unless request.env['warden'].user.is_admin?
end

But the .user method call comes up nil, so the is_admin? fails.

Any recommendations on how I can set this up?


Realized i just needed it in the application_controller

RailsAdmin.authorize_with do
  redirect_to root_path unless warden.user.is_admin?
end
0

精彩评论

暂无评论...
验证码 换一张
取 消