Created
May 11, 2010 11:45
-
-
Save jcxplorer/397211 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 Company | |
include Mongoid::Document | |
field :user_ids, :type => Array, :default => [] | |
field :admin_ids, :type => Array, :default => [] | |
def users | |
User.where(:_id.in => self.user_ids) | |
end | |
def admins | |
User.where(:_id.in => self.admin_ids) | |
end | |
end | |
class User | |
include Mongoid::Document | |
def companies | |
Company.where(:user_ids => self.id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment