Rails路由 - :on =>:集合

Nic*_*nto 24 routing rails-routing ruby-on-rails-3

Rails的路由指南没有明确规定什么:on => :collection意思.

我无法找到:on关键是什么的解释,也不能解释:collection那个背景中的含义.

Tho*_*emm 53

此处列出集合上的路由.

:on => :collection和之间的区别:on => :member是他们生产的路线风格及其相关的路线助手.

resources :posts do
  # on collection
  get 'search', on: :collection 
  # --> generates '/posts/search' and search_posts_path

  # on member
  get 'share', on: :member      
  # --> generates'/posts/:id/share' and share_photo_path(@post)
end
Run Code Online (Sandbox Code Playgroud)