1

I am working on a legacy app and am trying to upgrade it to Rails 3. Currently when I do a search I get the URL: http://localhost:3000/search/external_search/?keyword=argentina. However, when I try to filter out the results, I get http://localhost:3000/search/external_search/?order=Name:ASC, without the keyword parameter in the URL. Since there wasn't a keyword params, the filter wouldn't work. This was messing up my filter, so I decided to add a hidden field tag

<%= hidden_field_tag 'keyword', @search.text %>

which makes it work, but the URL didn't change. I want it to look like:

http://localhost:3000/search/external_search/?keyword=argentina&order=Name:ASC

Where exactly would I accomplish this? In the controller or the form?

1
  • The params hash in ROR doesn't care where the variables come from. What's in your controller code? Commented May 13, 2013 at 14:49

1 Answer 1

1

If you want to see the parameters of the submited form in the URL, you must use GET method instead of POST.

Add the option :method => :get to the form_for or form_tag enclosing the <%= hidden_field_tag 'keyword', @search.text %>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.