Results 1 to 6 of 6
Dec 29, 2007, 10:58 #1
- Join Date
- Aug 2006
- 0 Post(s)
- 0 Thread(s)
Cannot create new record--all fields are null
I have a form that has all the patient fields and it submits back to the appropriate controller action to initialize a new patient object and save the record.
I am getting this exception:
Mysql::Error: Column 'weight' cannot be null: INSERT INTO patients (`address1`, `city`, `status`, `address2`, `prognosis`, `weight`, `zip_code`, `gender`, `height`, `date_of_birth`, `first_name`, `last_name`, `state`) VALUES(NULL, NULL, NULL, NULL, '', NULL, NULL, '', NULL, NULL, '', '', NULL)
This is the code that is generating the error:
p = Patient.new(params[:patient]) p.save
If I change all the table fields to allow null values, the patient record is saved (obviously completely blank).
Also, to convince myself it is not me... I enabled the patient scaffold and tried to create a new patient through the generated form and it is giving the same exact error!