我的模型设置为
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,我宁愿不添加一个,因为如果该部分属于已经有一个的电影,这似乎是多余的。