Re-filling a form with no model

Probably a basic question here. I have a search form with a bunch of
criteria in checkboxes, selects, text fields, etc. When the form is
submitted I’d like it to be re-displayed with the previous values
(along with search results if any)

I know how to do this with <% form_for @thing %> and assigning @thing to
an instance of something in the controller. But since the search terms
are not tied to a model or any other object, they are just in
params[:terms] for instance - how do you do it easily?


Probably not the most elegant solution, but you could just do something
like this:

<input name=“mycheckbox” value=“true” type=“checkbox” <%= “checked”
unless params[:mycheckbox].nil? %>>

Good Luck,

  • Eric

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs