Reputation: 4811
I have an role
column in my User
model and I want to prevent someone from accessing the rails_admin routes if they don't have an admin
flag. Since the RailsAdmin::MainController
doesn't inherit from ApplicationController
I'm not sure how I can insert this check before the view loads.
I'm not keen on creating a new Admin
model as per the devise docs. I would like to use the same user account.
Does anyone have any suggestions? =)
Upvotes: 0
Views: 408
Reputation: 4629
You can define from which controller your rails admin will inherit by defining it in the config/initializers/rails_admin.rb file like this:
RailsAdmin.config do |config|
config.parent_controller = '::ApplicationController'
end
And also i recommend using a gem to handle authorization, cancancan or pundit will handle nicely your use case.
Upvotes: 1