On 9/7/05, ded <ded-google / ddoherty.net> wrote:
> 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:

It constructs a DBI::Date object, not a Date object. Active Record has
no idea what a DBI::Date object is, nor how it relates to a date, so
it tries to save it by marshalling with YAML. I haven't used
DBI::Date, but if there is a #to_time method, use it before assigning
the attribute, otherwise you can do something like:
  owner.filed_on = Time.local(dbi_record.filed_on.year,
dbi_record.filed_on.month, ... )

Again, not sure of the API, but you should get the idea.

-- 
David Naseby
http://homepages.ihug.com.au/~naseby/