Skip to content

Instantly share code, notes, and snippets.

@paulelliott
Created May 4, 2011 16:43
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 paulelliott/955541 to your computer and use it in GitHub Desktop.
Save paulelliott/955541 to your computer and use it in GitHub Desktop.
reference to embedded document
class Employee
include Mongoid::Document
referenced_in :company
field :team_id, type: BSON::ObjectId
def team
company.teams.find(team_id)
end
def team=(team)
self.company = team.company
self.team_id = team.id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment