secret
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
require 'pp'
require 'rubygems'
require 'mongo_mapper'
 
MongoMapper.connection = Mongo::Connection.new
MongoMapper.database = 'testing'
 
class Address
include MongoMapper::EmbeddedDocument
key :address, String
end
 
class Person
include MongoMapper::Document
many :addresses
end
 
Person.collection.remove
 
person = Person.new
person.addresses << Address.new(:address => 'Home sweet home')
person.save
 
pp person
pp person.addresses
 
person.reload
 
pp person
pp person.addresses
pp Person.collection.find.to_a

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.