Skip to content

Instantly share code, notes, and snippets.

@mattfawcett
Created November 20, 2009 16:06
Show Gist options
  • Save mattfawcett/239583 to your computer and use it in GitHub Desktop.
Save mattfawcett/239583 to your computer and use it in GitHub Desktop.
require 'rubygems'
gem 'activesupport', :version => "2.3.4"
require 'activesupport'
gem 'mongo_mapper', :version => "0.6.0"
require 'mongo_mapper'
MongoMapper.database = "mongo_mapper_issue_test"
class Person
include MongoMapper::Document
many :communications
key :email_address, String, :index => true
end
class Communication
include MongoMapper::EmbeddedDocument
key :channel, String
end
Person.destroy_all
matt = Person.create(:email_address => "matt@test.com")
matt.communications << Communication.new(:channel => 'email')
matt.save!
count = Person.count(:email_address => "matt@test.com")
puts "there are #{count} people"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment