Hi Rails experts,
I have one doubt regarding map.resources.
I am not clear with when to use :method and :collection in map.resources. Please help me out.
Thanks.
Hi Rails experts,
I have one doubt regarding map.resources.
I am not clear with when to use :method and :collection in map.resources. Please help me out.
Thanks.
Nilesh Kumar wrote:
Hi Rails experts,
I have one doubt regarding map.resources. I am not clear with when to use :method and :collection in map.resources. Please help me out.
Thanks.
method is for adding new actions that deal with a single instance of the mode in question.
collection is for adding new methods that deal with, well, a collection of the model in question.
I have:
map.resources :projects, {:collection => {:recent => :get}, :member => {:copy => :get, :pdf => :get}}
so I have a "recent projects" that works on the collection of projects(returning the most recent 10), and "copy" and "pdf" that work on an individual project.
Thanks Pratik for ur reply!
Thanks Chron for ur reply!