Skip to content

Instantly share code, notes, and snippets.

@benphelps
Created May 24, 2012 18:26
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 benphelps/8dfad988528fc9fbc394 to your computer and use it in GitHub Desktop.
Save benphelps/8dfad988528fc9fbc394 to your computer and use it in GitHub Desktop.
class Host < ActiveRecord::Base
attr_accessible :delay, :error, :host, :port, :status
has_many :checks
has_many :relations
has_many :users, through: :relations
end
class Relation < ActiveRecord::Base
attr_accessible :host_id, :user_id
belongs_to :host
belongs_to :user
end
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
has_many :relations
has_many :hosts, through: :relations
has_one :phone
def host
Hosts.where(:user_id, id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment