rails route question

Posted by badnaam on Stack Overflow See other posts from Stack Overflow or by badnaam
Published on 2010-06-07T21:59:30Z Indexed on 2010/06/07 22:02 UTC
Read the original article Hit count: 143

Filed under:

I am trying to build a search functionality which at a high level works like this.

1 - I have a Search model, controller with a search_set action and search views/partial to render the search. 2 - At the home page a serach form is loaded with an empty search object or a search object initialized with session[:search] (which contains user search preferences, zip code, proximity, sort order, per page etc). This form has a post(:put) action to search_set.

3 - When a registered user performs a set the params of the search form are collected and a search record is saved against that user. If a unregistered user performs a search then the search set action simply stores the params in the session[:search]. In either case, the search is executed with the given params and the results are displayed. At this point the url of in the location bar is something like..

http://localhost:3000/searches/search_set?stype=1

At this point if the user simply hits enter on the location bar, I get an error that says "No action responded to show" I am guessing because the URL contains search_set which uses a put method and even though I have a search_show (:get) action (which simply reruns the search in the session or saved in the database) does not get called.

How can I handle this situation where I can route a user hitting enter into the location bar to a get method?

If this does not explain the problem , please let me know I can share more details/code etc.

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails