Scaffold for boolean fields

The default scaffold generator generates the following code for a
boolean field. This results in a past selection not being remembered
during edits.


False True

I guess it should be:
<%= 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?

  • bhaskar

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 :slight_smile:

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

I prefer checkboxes for booleans… it’s quicker and just makes more
from a usability standpoint.

<%=check_box :model, :active %>

When you generate a form with scaffold_form_generator, that’s what you

If you’re looking for something more advanced than scaffolding, look at
ActiveScaffold or Streamlined, two very nice projects that take
to a whole new level, one that could be used in production (though I
think you should code your own user interfaces, but I’m an HTML guy at