Raymond O'Connor wrote:
I must be doing something dumb, but I can't figure this out.
The following code:
customer = Customer.new(:name => 'Ray', :date_created =>
Always results in the error ActiveRecord::RecordInvalid: Validation
failed: Date created can't be null
Yet, this code works fine:
customer = Customer.new(:name => 'Ray')
customer.date_created = Time.now.to_s(:db)
Is there something I'm doing wrong that is preventing me from putting
everything in the new method?
Have you excluded date_created from mass updates via attr_accessible
or attr_protected? If so, the second method is the only way that
currently works, however I'd like to see new_unsafe, create_unsafe,
build_unsafe, attributes_unsafe=, and update_attributes_unsafe methods
that bypass protection for use in internal processing.
The other alternative is some problem with your Customer.initialize