Created
May 4, 2011 16:43
-
-
Save paulelliott/955541 to your computer and use it in GitHub Desktop.
reference to embedded document
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 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