views:

20

answers:

1

I have the following drop down box in a form for rails:

<%= f.select (:boolean, options_for_select([["Yes", 1], ["No", 0]])) %>

Other drop down boxes in the same form post correctly, but this one posts null. Others in the same form:

<%= f.select (:kids_in_college, %w{1 2 3 4 5 6 7 8}) %> #posts correctly
<%= f.select (:year, %w{2009-2010 2010-2011 2011-2012}) %> # posts correctly

Is there something wrong with my syntax?

A: 

I think problem is not with the select list. I think you have to handle it on controller side. Something like following

@obj.boolean = (params[:obj][:boolean]=="1")? true : false

Note:- As per my knowledge most likely problem will be you are trying to input "String" in the field where boolean is expected.

Salil
I tried this, still doesn't work. My field type is an integer; I tried changing to a boolean and changing the inputs to true/false, but no dice. Wouldn't I get a type mismatch error it that were the case?
jakefuentes
Are you using either "attr_accessible" or "attr_protected" in the Model?
Salil