Posts Tagged ‘active record’

Rails, PostgreSQL and Time

Wednesday, May 9th, 2007

I just noticed that the mapping between PostgreSQL’s Time Without TimeZone column type maps to Rubys standard Time class. Which gives the following behavior in script/console:

   >> t = TimeEntry.find(1)
   >> t.time
   => Sat Jan 01 23:00:00 +0100 2000
   >> t.time = Time.now
   => Wed May 09 19:02:07 +0200 2007
   >> t.save
   => true
   >> t = TimeEntry.find(1)
   >> t.time
   => Sat Jan 01 19:02:07 +0100 2000

Am I very anal to find this … sloppy?

has_many :through and callbacks

Friday, April 27th, 2007

Reading this a little bit earlier would have saved me a lot of time. In short: callbacks such as :before_add does not work with has_many :through, and the documentation does not tell you that. To get callbacks, add them to the join model.