I am trying to convert one db to Active Record based objects, so I read
in the rows from the old db, create an AR object, then do o.save.
Both dbs are postgres. One of the fields is a date field.
When I read it from the old table with dbi, the system recognizes it as
a date field and contructs a Date object. But when I assign the object
to an attribute in the AR object, then do o.save, I get this error
message:
···
====================================
/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:462:in
`log': ERROR: invalid input syntax for type date: "---
!ruby/object:DBI::Date (ActiveRecord::StatementInvalid)
day: 23
month: 4
year: 2004"
: INSERT INTO owners ("city", "filed_on", "name", "zip", "middle",
"street1", "country", "last", "street2", "cik", "first", "is_entity",
"eolid", "hon", "stamp", "state", "suffix") VALUES('Oakland', '---
!ruby/object:DBI::Date
day: 23
month: 4
year: 2004', 'BERRIE ANGELICA', '07436', '', '40 Russ Berrie & Co Inc',
'United States', 'Berrie', '111 Bauer Drive', 1249690, 'Angelica', 'f',
NULL, '', NULL, 'NJ', '') from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:109:in
`execute'
It's the filed_on field that is causing the problems and the only Date
field in the record.
Anyone know what the problem is? My suspicion is that the postgres
adapter for AR is not able to cope with postgres 'date' fields, which
is puzzling for such a fundemental data type.
I would appreciate any help. I am new to Ruby and, of course, active
record.
Thanks.