Skip to content

Instantly share code, notes, and snippets.

@RaMin0
Created January 26, 2012 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaMin0/1680662 to your computer and use it in GitHub Desktop.
Save RaMin0/1680662 to your computer and use it in GitHub Desktop.
class Child
include Mongoid::Document
# Attributes
field :born_on, class: Date
# Relations
embedded_in :parent
end
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