Rails路由:浅=>真

bot*_*bot 4 ruby routes ruby-on-rails

想知道为什么申请时我的/文章路线不会出现:shallow => true?

的routes.rb

resources :users, :shallow => true do
  resources :articles
end
Run Code Online (Sandbox Code Playgroud)

还试过这个:

resources :users do
  resources :articles, :shallow => true
end
Run Code Online (Sandbox Code Playgroud)

访问/文章不会按预期向我显示任何用户的所有文章,但我仍然可以访问/ articles /:id就好了.这是预期的行为吗?

Pet*_*own 13

shallow: true选项不根据文档提供索引资源.因此,您将无法访问/articles.所以是的,这是预期的行为.