Should I use CanCan Active Admin user?

I use Devise and CanCan for authorization in the interface of the Rails 3 application. I also have Active Admin as the interface for the backend. I am trying to create different roles for administrators in the backend. Both ends have an entry form that uses different "user" models and tables. The problem is that CanCan extracts the current user from the interface (captures the current user object) and uses it to make sure that someone from the backend has the correct permissions.

So, how can I CanCan correctly grab the registered admin user?

If someone needs more information, I will be happy to provide it.

+6
source share
1 answer

I have not used ActiveAdmin , but used Devise and Cancan in several projects before.

By looking at the Active Admin Documentation ,

Set the method that controllers must call to authenticate the current user:

  # config/initializers/active_admin.rb config.authentication_method = :authenticate_admin_user! 

Set the method to call in the view to access the current admin user

  # config/initializers/active_admin.rb config.current_user_method = :current_admin_user 

You can override Cancan behavior in your application by looking at :current_admin_user instead of :current_user .

See here Cancan changes the default values .
If you still cannot get it, report your problems where you are stuck.

+9
source

Source: https://habr.com/ru/post/893156/


All Articles