Does anyone have experience with using boolean fields (Postgres here,
but I
assume it’s the same on MySQL)? Is there any reason the scaffold
generator
explicitly writes out the whole tags rather than use select helpers? It
has
a default value specified that does not reflect the DB (always false).
The
code is also not XHTML compliant (selected is just selected, not
selected=“selected”, which seems strange, since as far as I can tell,
usual
generated Rails code seems to be nice and XHTML compliant).
I made my own little true / false option select helper, but it doesn’t
reflect
the database either.
The code was literally cut and pasted from another bit of my app where I
use
the same technique to have a select list of options, and that time it
does
represent the database perfectly (it’s basically like some kind of enum
list,
which this little true/false selector is too).
But my boolean select thing won’t reflect the database, even though it
does a
perfect job of altering the values when I change them. Here’s the code
it’s ridiculously simple, so I have no idea why it’s not working as I
hoped:
def boolean_select(object, fieldname, options ={})
select(object, fieldname, {“True” => “true”, “False” => “false”},
options)
end
I also previously tried:
def boolean_select(object, fieldname, options ={})
select(object, fieldname, %w{true false}, options)
end
It doesn’t work, and I’m puzzled by it!
Best regards,
~Dave
–
Dave S.
Rent-A-Monkey Website Development
Web: http://www.rentamonkey.com/