Hi,
I've added a column to a db in rails via a migration, and updated new.html.erb to add the field to the form.
The correct data is in the request params, but the insert query that is generated has a null for the column every time.
Here are the request params:
{"commit"=>"Create",
"assignment"=>{"start_date"=>"08/04/2010",
"project_id"=>"5",
"allotment"=>"50",
"person_id"=>"33",
"end_date"=>"08/05/2010"},
"authenticity_token"=>"8f157a2a220caf716607162ce9557ab6505aab1a"}
and here is the resulting error with query showing the null column:
Mysql::Error: Column 'end_date' cannot be null:
INSERT INTO `assignments` (`start_date`, `created_at`, `project_id`, `updated_at`, `allotment`, `person_id`, `end_date`)
VALUES('2010-08-04', '2010-08-04 03:36:21', 5, '2010-08-04 03:36:21', 50, 33, NULL)
Here's the migration in question:
class ChangeDates < ActiveRecord::Migration
def self.up
add_column :assignments, :end_date, :date, :null => false
rename_column :assignments, :date, :start_date
end
def self.down
remove_column :assignments, :end_date
rename_column :assignments, :start_date, :date
end
end
I can't figure out what went wrong. I've rolled back and migrated the change a couple of times with no luck. I'm stumped.