Skip to content

Instantly share code, notes, and snippets.

@mipearson
Created March 21, 2011 05:16
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 mipearson/879071 to your computer and use it in GitHub Desktop.
Save mipearson/879071 to your computer and use it in GitHub Desktop.
class Match
include Mongoid::Document
include Mongoid::Timestamps # adds created_at and updated_at fields
field :scheduled_start, :type => Date
field :status
embeds_one :home_team
embeds_one :away_team
end
class Team
include Mongoid::Document
field :shortName
field :name
end
class HomeTeam < Team
embedded_in :match, :inverse_of => 'home_team'
end
class AwayTeam < Team
embedded_in :match, :inverse_of => 'away_team'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment