Rails CanCan:CanCan 是否假设我可以:读取,如果我可以:更新?
这适用于授权!调用
can [:read,:update], brand
,但当 Skill 类中的行更改为:
can :update, brand
brand is not nil 时,会抛出 CanCan::AccessDenied 。
如果我可以 :update 某些内容,我难道不应该自动能够 :read 吗?
我只是想知道这是否是设计使然,或者我是否在某个地方遗漏了某些东西。
This works for an authorize! call
can [:read,:update], brand
but CanCan::AccessDenied is thrown when the line in the Ability class is changed to:
can :update, brand
brand is not nil.
If I can :update something, shouldn't I automatically be able to :read it?
I just want to know if this is by design, or if I am missing something somewhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是设计使然。定义的默认别名很少:
因此,如果某人拥有“更新”权限,那么他就拥有“编辑”权限。这对于遵循 REST 风格的 Rails 应用程序来说是很自然的。
但是,您可以非常简单地定义您自己的别名。
This is by design. There are just few default aliases defined:
So if someone has 'update' right then he has 'edit' right. This is natural for Rails applications which follow REST style.
However you can define your own aliases very simply.