-
-
Save benphelps/8dfad988528fc9fbc394 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 Host < ActiveRecord::Base | |
attr_accessible :delay, :error, :host, :port, :status | |
has_many :checks | |
has_many :relations | |
has_many :users, through: :relations | |
end |
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 Relation < ActiveRecord::Base | |
attr_accessible :host_id, :user_id | |
belongs_to :host | |
belongs_to :user | |
end |
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 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