class Ability
include CanCan::Ability
user ||= User.new # guest user (not logged in)
if user.admin
can :manage, :all
else
can :read, :all
end
end
I am using has_many through association. Having 3 tables - User, Role and UserRole. UserRole table is used to connect users and roles tables. In UserRole table I am storing user_id and role_id. There is no attribute named admin. How do I change the above code to check if the user is admin?
rolifygem for sure. Sneha check once in gemfile whether it contains rolify - rayUser.instance_methods.map(&:to_s).select { |x| x.match /admin/ }in rails console, what does it provide? - ray