Forum: Ruby on Rails Route in layout doesn't work with params

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.
Guest (Guest)
on 2007-01-19 03:51
Say you have a search route that posts to the create resource in the
search controller called from the layout RHTML. All is fine until you go
to a route that takes an ID, say like items/2, and try to do a search
from there. So the items will change to search but the 2 will be with it
(search/2) and a routing error will occur:

Routing Error

no route found to match "/search/2" with {:method=>:post}


So to be thorough, in my application.rhtml layout that is in place for
every controller, I have for_form :search, :url => search_url, and that
causes a routing issue from URLs that have a value being passed in.

Any help would be great!
Guest (Guest)
on 2007-01-19 17:41
NM, it works with a custom named route.

Guest wrote:
> Say you have a search route that posts to the create resource in the
> search controller called from the layout RHTML. All is fine until you go
> to a route that takes an ID, say like items/2, and try to do a search
> from there. So the items will change to search but the 2 will be with it
> (search/2) and a routing error will occur:
>
> Routing Error
>
> no route found to match "/search/2" with {:method=>:post}
>
>
> So to be thorough, in my application.rhtml layout that is in place for
> every controller, I have for_form :search, :url => search_url, and that
> causes a routing issue from URLs that have a value being passed in.
>
> Any help would be great!
This topic is locked and can not be replied to.