It seems that validations in DataMapper run before dm-timestamps has a chance to autoset the created_at and updated_at fields.
Consider the following:
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
require 'dm-validations'
class MyResource
include DataMapper::Resource
property :mykey, Serial, :key=>true
property :created_at, DateTime, :required=>true
property :updated_at, DateTime
end
resource = MyResource.new
resource.save #fails
The save fails because created_at is blank. Interestingly, if you just comment out the "require dm-validations", the problem goes away. Of course, you can also just remove ":required=>true" from :created_at but that's not what I'm after - created_at is required. It's just that I'm using dm-timestamps to automatically set it for me.
Anyone else seen this? Is there a solution?