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
精彩评论