[Rails] another select_list question - bad bad booleans
Craig White
craigwhite at azapple.com
Wed Mar 1 06:36:28 GMT 2006
I have a select list for a boolean column in postgresql
in the 'model' ...
YES_NO = [
[ "Yes", "1" ],
[ "No", "0" ]
].freeze
in the 'view code' ...
<%= options = [['Accepted?', '']] + Placement::YES_NO
select("placement", "accepted", options) %>
When creating new records, I can select Yes or No and it writes the
proper value to table.
When I edit existing records, unlike other select list menus which
automatically go to the existing value in the select list, the
'Accepted' list always displays "Accepted?' (the prompt, never the
value) in the pop-up selected list, no doubt because it cannot figure
out the reverse translation of existing column 0's and 1's backwards to
Yes : No logic.
What is the trick to do that?
Thanks
Craig
More information about the Rails
mailing list