Multiple calls to map.resources not working

I need to extend a RESTful controller (ads) with two aditional actions (search and coincidences), so I include the following code in my routes.rb file:

map.resources :ads, :collection => {:coincidences => :get} map.resources :ads, :collection => {:search => :get}

however, I can only get one of these sentences to work - the one that comes first. The second one seems to be ignored.

How can it be fixed?

map.resources :ads, :collection => {:coincidences => :get, :search => :get}

Thanks Wolas, worked like a charm. I knew it had to be something as easy as that, but couldn't find any examples. Thanks again.


I saw it and I had to comment… a search doesn’t really need its own additional action. Search just returns records (in your case, ads), but with a filter applied. Generally, if you’re doing RESTful design, Search forms just do GET to the Index action, and the controller checks parameters to determine how the results get populated.