Rails 5 gens rails_admin, devise, cancancan
I have a User Template : string, ..., admin_role: boolean, employee_role: boolean, user_role: boolean}
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
can :read, :all # allow everyone to read everything
cannot :manage, [Gender]
return unless user.admin_role? || user.employee_role?
can :access, :rails_admin # only allow admin and employee users to access Rails Admin
can :dashboard, :all # allow access to dashboard
if user.admin_role?
can :manage, :all # allow superadmins to do anything
elsif user.employee_role?
can :update, [User], admin_role: false
end
end
end
As "can: update, [User], admin_role: false" I can "edit" only those who are not administrators, but I can not save the edit ..
What am I doing wrong?