Can't seem to map a route as GET for controller/search/term


#1

Hi all,

I’m making a search features for a record with a keywords field
(keywords is a string right now), and my routing is having consistency
troubles. What I desire is:

localhost:3000/controller/search/:keyword

I would like this form to be obeyed for both form-submitted searches and
the HTML links I generate. However, :method => :get is not being
obeyed, and my helper method returns “search?keyword=foo+bar”.

My routing is RESTful, and I have added the search action to the
map.resources call. If I call “controller/search/keyword” directly I
get this error:

undefined method `index_url’ for #SermonsController:0x4a0e1c4

I find this curious. My routing is before the map.connect call for the
standard format.

Here’s my map call:

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

If I map the following line, I get a 500 error.

map.search_sermons ‘sermons/search/:keyword’,
:controller => :sermons, :action => :search

As you can guess this is confusing me.

Have I done anything wrong? My links are forced into the
“controller/search?keyword=foo+bar” format, and my forms remain POST
methods no matter what I try to override them with. How should I go
about routing this?

Thanks,
Robert

P.S. I currently have the site working with what I have, but I’d really
like to make it consistent with the rest of the site’s routing scheme.