Forum: Ruby on Rails Can't seem to map a route as GET for controller/search/term

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Robert K. (Guest)
on 2008-11-24 18:22
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.
This topic is locked and can not be replied to.