2
我有模型Owner
,Shop
和Item
。Rails_admin,使用cancan時模型列表顯示爲零
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
頁是空的。
但是,當我打開Shops頁面時,我可以看到它的所有項目,並且我可以在Shops頁面上更改它們。
當我寫我的代碼是這樣的:
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
上Items List
名單?