Skip to content

Instantly share code, notes, and snippets.

@carlhoerberg
Created February 1, 2012 21:27
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 carlhoerberg/1719570 to your computer and use it in GitHub Desktop.
Save carlhoerberg/1719570 to your computer and use it in GitHub Desktop.
Adding a hash to a DM collection makes two items
require 'dm-core'
DataMapper.setup(:default, 'in_memory::')
class A
include DataMapper::Resource
property :id, Serial
property :jada, String
has n, :bs
end
class B
include DataMapper::Resource
property :id, Serial
property :joda, String
end
DataMapper.finalize
a = A.create
a.bs << {:joda => 'test'}
a.save
p a.bs
#=> [#<B @id=1 @joda="test" @a_id=1>, #<B @id=1 @joda="test" @a_id=1>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment