what does this rails code do? :on => :member
ruby-on-rails
Solution
passing `:on => :member` means that you are working on a specific record in the database, in this case products. so the url that route generates is
`/products/:id/who_bought`
which means that you want the get the product whose id is :id and process the who_bought action. the counterpart, `:on => :collection`, expects the action to work on a list of products so the url will look like
`/products/who_bought`
if you change member to collection. you can see that the route doesn't require an :id passed because it doesn't expect you to work on a single record.
Problem
please can you explainme what does this code do? ``` resources :products do get :who_bought, :on => :member end ``` the code complete is from the book pragmatig programing, but it not explain why we use that code, ":on => :member"" ``` Depot::Application.routes.draw do resources :orders resources :line_items post 'line_items/decrease' resources :carts get "store/index" resources :products do get :who_bought, :on => :member end root :to => 'store#index', :as => 'store' ``` thanks