Mam taki formularz:
[code]…
<%= f.label :type %>
<%= f.select :type, Status_type.all.collect {|p, q| [q, p] } %>
respond_to do |format|
if @status.save
flash[:notice] = params[:status].inspect
format.html { redirect_to(@status) }
format.xml { render :xml => @status, :status => :created, :location => @status }
else
format.html { render :action => "new" }
format.xml { render :xml => @status.errors, :status => :unprocessable_entity }
end
end
end[/code]
I taką tabelę:
[code]…
create_table :statuses do |t|
t.integer :type
t.text :description, :null => true
t.datetime :date, :null => true
t.timestamps
end
…[/code]
Po wypełnieniu formularza niby wszystko ładnie dodaje. Przekazane dane pokazuje tak:
{"date(1i)"=>"2009", "date(2i)"=>"6", "date(3i)"=>"24", "notification_id"=>"1", "date(4i)"=>"08", "date(5i)"=>"19", "type"=>0, "description"=>"Banshee"}
ale mimo tego do bazy nie wpisywana jest wartość “type” z pola select (inne są) - w tabeli jest null.
Dlaczego tak się dzieje?
Pozdrawiam,
sebcioz