class Ability
include CanCan::Ability
def initialize(user)
@user = user || User.new
can :manage, :all
can :custom_action, User, role: 'admin'
end
end
and in view
if can? :custom_action, @user
SHOW SOMETHING
this if always show “SHOW SOMETHING”, don’t understood why it’s happend.
Well, that’s because in your ability class, you give every user all rights.
You are probably looking for something like this:
This way, you define the abilities (by using
can) conditionally