Skip to content

Instantly share code, notes, and snippets.

@solnic
Created April 15, 2010 11:00
Show Gist options
  • Save solnic/366970 to your computer and use it in GitHub Desktop.
Save solnic/366970 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
DataMapper.setup :default, 'sqlite3::memory:'
class Foo
include DataMapper::Resource
property :id, Serial
property :name, String
property :created_at, DateTime
property :updated_at, DateTime
end
DataMapper.auto_migrate!
foo = Foo.create :name => 'foo'
puts foo.inspect # has timestamps
foo.reload
puts foo.inspect # nil timestamps
foo.save # nil timestamps are persisted
puts foo.created_at # nil
puts foo.updated_at # nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment