![](/img/trans.png)
[英]declarative_authorization and /authorization_rules access problem
[英]Declarative_Authorization nested rules
我的模型設置為
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內嵌套:sections的規則嗎? 部分中沒有user_id,因此我不願添加一個,因為如果該部分屬於一部已經擁有一部的電影,這似乎是多余的。
是的,您可以嵌套它們,
has_permission_on [:films], :to => [ :edit, :update] do
if_attribute :user => is {user}
has_permission_on :sections, :to => [:update, :edit]
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.