加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails路由:浅=>真

发布时间:2020-12-17 04:05:05 所属栏目:百科 来源:网络整理
导读:想知道为什么申请时我的/文章路线不会出现:shallow =真正? 的routes.rb resources :users,:shallow = true do resources :articlesend 还试过这个: resources :users do resources :articles,:shallow = trueend 访问/文章不会按预期向我显示任何用户的所
想知道为什么申请时我的/文章路线不会出现:shallow =>真正?

的routes.rb

resources :users,:shallow => true do
  resources :articles
end

还试过这个:

resources :users do
  resources :articles,:shallow => true
end

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

解决方法

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读