You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
I'm trying to user multi-role authorization with cancan.
In development mode everything is perfect! A typical user can have both 'normal' and 'moderator' roles which each has defined permissions. And I can debug and log what happens in initialize method. The permissions are concatenated for this user.
But in production mode, this does not work! I cannot debug ability.rb. And even I authorize the user with all permissions, he cannot access the permissions of the 2nd role:
def initialize(user)
can :manage, :all
...
end
These are the methods in application_controller.rb
def current_ability
cache_key = (current_user.present? ? "#{current_user.cache_key}::ability" : "unsigned_user::ability")
@current_ability = Rails.cache.fetch(cache_key) do
super
end
end
def load_permissions
if user_signed_in?
@current_permissions = Rails.cache.fetch("#{current_user.cache_key}::permissions") do
temp = Array.new
current_user.roles.each do |role|
role.permissions.map{ |p| temp << [p.subject_class, p.action] }
end
temp
end
end
end
Help me! Thank you.
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to user multi-role authorization with cancan.
In development mode everything is perfect! A typical user can have both 'normal' and 'moderator' roles which each has defined permissions. And I can debug and log what happens in initialize method. The permissions are concatenated for this user.
But in production mode, this does not work! I cannot debug ability.rb. And even I authorize the user with all permissions, he cannot access the permissions of the 2nd role:
These are the methods in application_controller.rb
Help me! Thank you.
The text was updated successfully, but these errors were encountered: