Forum: Ruby on Rails re-filling a form with no model

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
56eb877c42e47774db729bcfb8cad46f?d=identicon&s=25 sbeam (Guest)
on 2007-05-09 18:26
(Received via mailing list)
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?

7f38b0730b4ec046dde96341236fcc5f?d=identicon&s=25 Eric A. (xmg-eric)
on 2007-05-09 22:02
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 topic is locked and can not be replied to.