Skip to content

Instantly share code, notes, and snippets.

class Vlan < ActiveRecord::Base
include VlanType
validates_inclusion_of :type, :in => [:public, :private, :static]
end
class Component < ActiveRecord::Base
belongs_to :cabinet
belongs_to :component_model
has_many :port, :as => :device, :extend => CreatePortFromModel
has_many :sub_components
def elevation
orientation + elevation_index.to_s
end
class Component < ActiveRecord::Base
belongs_to :cabinet
belongs_to :component_model
has_many :port, :as => :device, :extend => CreatePortFromModel
has_many :sub_components
def elevation
orientation + elevation_index.to_s
end
class Cabinet < ActiveRecord::Base
has_many :components do
def front_facing
all(:conditions => {:orientation => "A"})
end
def front_facing_grouped_by_elevation_index
front_facing.group_by{|component| component.elevation_index - component.component_model.height + 1}
end
class Component < ActiveRecord::Base
has_many :sub_components
#this is the 'other side' of the has_many :components statement
belongs_to :component
has_one :component
end