我有一个routes.rb
看起来像这样的:
resources :restaurants, :shallow => true do
resources :orders do
resources :foods
end
resources :categories do
resources :foods
end
end
ability.rb
我的作品中有这样的东西,
if user.role? :owner
can :manage, Category, :restaurant => {:user_id => user.id}
...
但是更深的嵌套似乎是浅嵌套的问题。
can :manage, Food, :category => {:restaurant => {:user_id => user.id}}
end
关于如何让 CanCan 处理与上一个示例一样深的嵌套的任何想法?