The default scaffold generator generates the following code for a
boolean field. This results in a past selection not being remembered
during edits.
Active
False
True
I guess it should be:
Active
<%= select(“model”, “active”, [[‘True’, true],[‘False’, false]]) %>
This seems to be a rather basic operation for the scaffolding
generator to get wrong. Am I missing something?
FYI: I am using Rails 1.2.5 (through InstantRails + update).
First off:
Yes, it’s basic. Because scaffolding is basic. It’s also not meant for
production use.
Second, people like the scaffolding because it builds forms for them
I just released a gem called scaffold_form_generator that does the form
generation part of scaffolding (no controller, no model, just the form).
It’s really meant for use in Rails 2.0 apps though since it uses RESTful
routing and the new .html.erb syntax for forms.
You can learn more about that at http://scaffoldform.rubyforge.org
I prefer checkboxes for booleans… it’s quicker and just makes more
sense
from a usability standpoint.
<%=check_box :model, :active %>
When you generate a form with scaffold_form_generator, that’s what you
get.
If you’re looking for something more advanced than scaffolding, look at
ActiveScaffold or Streamlined, two very nice projects that take
scaffolding
to a whole new level, one that could be used in production (though I
still
think you should code your own user interfaces, but I’m an HTML guy at
heart.)