Skip to content

Instantly share code, notes, and snippets.

@fcoury
Created July 19, 2009 08:37
Show Gist options
  • Select an option

  • Save fcoury/149851 to your computer and use it in GitHub Desktop.

Select an option

Save fcoury/149851 to your computer and use it in GitHub Desktop.
class Address
include MongoMapper::EmbeddedDocument
key :address
key :city
key :country
end
class Customer
include MongoMapper::Document
key :name, :required => true
many :addresses
end
customer = Customer.new(:name => "Felipe Coury")
customer.save #=> true
address = Address.new(:address => "203 Main St.", :country => "Brazil")
address.save #=> NoMethodError: undefined method ‘save’ for #<Address":0x123a248>
customer.addresses << address
customer.save #=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment