I have the following routes set up in my routes.rb file:
resources :people do
collection do
get :search
end
end
When i do a get action on the url: http://localhost:3000/people/search.json?term=stepeb, the server reports that it's responding with the show action, with the correct term parameter, but also has an id parameter, set to "search".
The problem, as i see it, are the two urls the show url would be:
/people/:id
and i believe that the router is matching that route before it gets to /people/search
If that is the case, how would collection based routes ever work? Wouldnt they all get caught by the show action?
The relevant part of rake routes is as follows:
search_people GET /people/search(.:format) {:action=>"search", :controller=>"people"}
GET /people(.:format) {:action=>"index", :controller=>"people"}
people POST /people(.:format) {:action=>"create", :controller=>"people"}
new_person GET /people/new(.:format) {:action=>"new", :controller=>"people"}
GET /people/:id(.:format) {:action=>"show", :controller=>"people"}
PUT /people/:id(.:format) {:action=>"update", :controller=>"people"}
person DELETE /people/:id(.:format) {:action=>"destroy", :controller=>"people"}
edit_person GET /people/:id/edit(.:format) {:action=>"edit", :controller=>"people"}