【发布时间】:2015-07-28 09:50:10
【问题描述】:
我有模型Owner、Shop 和Item。
Owner 有很多Shops,Shops 有很多Items。
我在康康舞方面的能力:
can :manage, Shop, owner_id: user.id
can :manage, Item, shop: {owner_id: user.id}
当我打开 rails_admin 仪表板时,它显示我的 Items 为零,而页面 List of Items 为空。
但是,当我打开商店页面时,我可以看到其中的所有商品,并且可以在商店页面上更改它们。
当我这样写代码时:
can :manage, Item do |item|
item.shop.owner_id == user.id
end
它给我一个错误:
The accessible_by call cannot be used with a block 'can' definition. The SQL cannot be determined for :index Item
为什么我不能在Items List 上列出我所有的Items?
【问题讨论】:
标签: ruby-on-rails cancan rails-admin cancancan