secret
Created

  • Download Gist
host.rb
Ruby
1 2 3 4 5 6
class Host < ActiveRecord::Base
attr_accessible :delay, :error, :host, :port, :status
has_many :checks
has_many :relations
has_many :users, through: :relations
end
relation.rb
Ruby
1 2 3 4 5
class Relation < ActiveRecord::Base
attr_accessible :host_id, :user_id
belongs_to :host
belongs_to :user
end
user.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.