CanCanCan用户不能删除他们的并且不能编辑属于他们的某些属性

问题描述

我想知道在这种情况下用户是否有可能具有以下属性的管理员:用户名,电子邮件,密码,照片,性别,角色。可以编辑他们的帐户,因此可以更改上述名称属性(电子邮件和角色除外)的值。他们也不能删除他们的帐户。我目前的状态是

  include CanCan::Ability

  def initialize(user)
    # Define abilities for the passed in user here. For example:
    user ||= User.new
    #other abilities
    return unless user.admin?
    can :manage,:all
    cannot [:update,:destroy],User,id: user.id
  end
end

这不允许用户(管理员)删除她的帐户,这很不错,但是在进行编辑时,管理员可以编辑帐户中的所有属性,她不能仅编辑角色和电子邮件

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...