【发布时间】:2013-06-05 19:58:46
【问题描述】:
我想根据嵌套资源的属性过滤模型,例如:
can :read, Model, has_many_relation: { attribute: attr }
使用这种形式的块的问题:
can :read, Model do |obj|
obj.has_attribute(attr)
end
是该权限只能在获取单个模型时使用(调用加载#index操作时忽略该权限)。
如何使用基于 has_many 关系的条件过滤模型?
【问题讨论】:
标签: ruby-on-rails activerecord cancan