Created
July 19, 2009 08:37
-
-
Save fcoury/149851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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