Skip to content

Instantly share code, notes, and snippets.

@jnunemaker
Created December 31, 2011 18:30
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 jnunemaker/911a2b460e50790f7da4 to your computer and use it in GitHub Desktop.
Save jnunemaker/911a2b460e50790f7da4 to your computer and use it in GitHub Desktop.
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