Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:911a2b460e50790f7da4
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.