class Ability
include CanCan::Ability
def initialize(user)
@user = user || User.new
can :manage, :all
can :custom_action, User, role: 'admin'
end
end
并且在视野中
if can? :custom_action, @user
SHOW SOMETHING
如果总是显示“显示某些东西”,不明白为什么会发生这种情况。