I have successfully created a login system using Devise and CanCan, and I have 3 types of users. Administrators, internal and global users. I created controllers and index actions: Admin, Cpanel, Report, and State, and I want to restrict access to these controllers for some users.
Admin user must have access privileges: reports (all), status (read), Admin (all)
The global user must have access privileges: reports (read only), status (read), cpanel (all)
The internal user must have access privileges: reports (all), status (read)
And I tried to do this with the following code in the .rs capabilities file :
class Ability include CanCan::Ability def initialize(user) user ||= User.new
At this time, I only have index actions in these controllers, and when I log in to the application with an internal user, I can connect to / admin, for example, and this is not the behavior I want. I want to restrict access to all controllers, not the controllers listed in the capability.rb class.
Source code here
source share