问题
I use pundit gem to authorization.
In my file config/initializers/rails_admin.rb
RailsAdmin.config do |config|
config.authorize_with :pundit
config.current_user_method(&:current_user)
......
end
I follow the instructions in https://github.com/sudosu/rails_admin_pundit
But in when run code, error :
protected method `policy' called for #<Rails_Admin::MainController
I use rails_admin 0.8.1
Please guide me use pundit in rails_admin ( tutorial, examle, ...)
回答1:
You can try to use this gem or just make default authorization.
Add this to config/initializers/rails_admin.rb
file:
config.authorize_with do
redirect_to main_app.root_path, error: 'You are not authorized to perform this action.' unless current_user.admin?
end
来源:https://stackoverflow.com/questions/36288801/authorization-rails-admin-with-pundit