Skip to content

Instantly share code, notes, and snippets.

@jnwelzel
Created August 13, 2012 18:22
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 jnwelzel/3342929 to your computer and use it in GitHub Desktop.
Save jnwelzel/3342929 to your computer and use it in GitHub Desktop.
Company -> User (owner)
class Company
include Mongoid::Document
include Mongoid::Timestamps
has_and_belongs_to_many :users
belongs_to :owner, class_name: "User", inverse_of: :owns
end
class User
include Mongoid::Document
include ActiveModel::SecurePassword
has_and_belongs_to_many :companies
has_many :owns, class_name: "Company", inverse_of: :owner
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment