开发者

How do I use the RailsAdmin.authorize_with method?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜