def initialize(user)
if user.has_role? :admin
can :manage, :all
can :destroy, User
can [:update , :destroy], [Article, Comment]
else
can :read, :all
end
如何让只有管理员删除用户,但不能删除自己?
我正在使用 wice_grid gem,我已将此添加到我的视图中,但管理员仍然可以删除自己
g.column do |user|
if can? :destroy, @user && !current_user(user)
link_to('Delete', user, method: :delete, data: { confirm: 'You sure?' })
end
end