Skip to content

Instantly share code, notes, and snippets.

@jcxplorer
Created May 11, 2010 11:45
Show Gist options
  • Save jcxplorer/397211 to your computer and use it in GitHub Desktop.
Save jcxplorer/397211 to your computer and use it in GitHub Desktop.
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