This had me going for a while!

I wanted to default a field to the epoch, i.e. some decades ago, or older. That’s because a batch process will work on the records with the oldest such field, so setting the field to epoch guarantees they’ll get priority initially.

I had a migration like such:

[ruby] t.datetime :acted_on, :default => 0 ### BAD [/ruby]

After some debugging, I notice FactoryGirl is setting the field to null. The fix is:

[ruby] t.datetime :acted_on, :default => ### GOOD [/ruby]

Note it’s for epoch, not, which will be the present time. (And you probably wouldn’t want that, because it would be the time you run the migration, not the time a given record is actually created. If you want creation time, use a before_create callback.)