Ok this is really starting to drive my nuts now so I was hoping someone
could give me a hand. I have a restaurant search form that allows people
to search out restaurants. I have a drop down that allows people to
narrow the search to a specific cuisine type. When the page first loads
I need a "Pick A Cuisine" prompt at the top of the list. The problem is
that if the user selects a cuisine type then submits the form the
selected value always goes back to the prompt. Can anyone please help
show me how to keep the selected value? Here is what I have so far:
Steve,
The reason this is not happening is that there isn't anything
automagical in Rails to do this for you. What you should do is save the
selection in a session variable when they submit the form, and then use
that session variable to set the current setting of the selector in your
view. (and condition the prompt on whether or not the session variable
has been set up yet).
Another option would be to put the cuisine id in the route
(routes.rb). I'm dealing with this in another app that has a similar
approach. You could also set a hidden field in a form if the cuisine
has been selected... Anyway, there are different ways to do this, so
explore your options and take your pick!
Ok I came up with an acceptable working solution. It may not be the best
one but I will post it anyway for all of you who are experiencing the
same problem.