Skip to content

Instantly share code, notes, and snippets.

@k2052
Created August 6, 2012 19:25
Show Gist options
  • Save k2052/3277777 to your computer and use it in GitHub Desktop.
Save k2052/3277777 to your computer and use it in GitHub Desktop.
Test Parent Child MongoMapper
require 'mongo_mapper'
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'playground'
class Parent
include MongoMapper::Document
key :name, String
many :children
end
class Child
include MongoMapper::EmbeddedDocument
belongs_to :parent
def parent=(parent)
super(parent)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment