Declarative_Authorization 嵌套规则
设置进行设置,
Film :has_many :sections
Section :belongs_to :film
我的模型按照我的authorization_rules.rb 中的
role :author do
has_permission_on :films, :to => [:edit. :update] do
if_attribute :user => is {user}
end
end
在编辑电影时效果很好,因为它们是电影中的 user_id 字段。
我可以在 has-permission-on do 块中嵌套 :sections 规则吗?部分内没有 user_id,我不想添加 user_id,因为如果该部分属于一部已经有 user_id 的电影,这似乎是多余的。
My models are setup as
Film :has_many :sections
Section :belongs_to :film
within my authorization_rules.rb I have
role :author do
has_permission_on :films, :to => [:edit. :update] do
if_attribute :user => is {user}
end
end
Which works fine when editing the film as their is a user_id field within film.
Can I nest rules for :sections within the has-permission-on do block? There is no user_id within sections, and I'd rather not add one as it seems redundant if the section belongs_to a film that already has one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你可以嵌套它们,
Yes you can nest them,