Created
January 26, 2012 02:52
-
-
Save RaMin0/1680662 to your computer and use it in GitHub Desktop.
This file contains 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 Child | |
include Mongoid::Document | |
# Attributes | |
field :born_on, class: Date | |
# Relations | |
embedded_in :parent | |
end |
This file contains 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 Parent | |
include Mongoid::Document | |
# Relations | |
embeds_many :sons, class_name: 'Child' | |
embeds_many :daughters, class_name: 'Child' | |
# Methods | |
def children | |
# get sons + daughters... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment