Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2010 04:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save xaviershay/716295 to your computer and use it in GitHub Desktop.
# Trying to replicate
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'$stdout, :debug)
DataMapper.setup(:default, 'postgres://localhost/test') # createdb test
class TestDm
include DataMapper::Resource
property :id, Serial
property :created_at, DateTime
property :created_on, Date
property :updated_at, DateTime
property :updated_on, Date
has n, :tests, :through => :testing
has n, :testing
class Testing
include DataMapper::Resource
belongs_to :test_dm, :key => true
belongs_to :test, :key => true
class Test
include DataMapper::Resource
property :id, Serial
has n, :testing
test = Test.create.tap do |t|
t.testing.create(:test => Test.create)
puts Marshal.load(Marshal.dump(test)).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment