Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Created November 26, 2010 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xaviershay/716295 to your computer and use it in GitHub Desktop.
Save xaviershay/716295 to your computer and use it in GitHub Desktop.
# Trying to replicate http://datamapper.lighthouseapp.com/projects/20609-datamapper/tickets/470-memcaching-can-t-marshal-dm-objects#ticket-470-19
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
DataMapper::Logger.new($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
end
class Testing
include DataMapper::Resource
belongs_to :test_dm, :key => true
belongs_to :test, :key => true
end
class Test
include DataMapper::Resource
property :id, Serial
has n, :testing
end
DataMapper.finalize
DataMapper.auto_migrate!
test = Test.create.tap do |t|
t.testing.create(:test => Test.create)
end
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