Skip to content

Instantly share code, notes, and snippets.

@bill-transue
Created September 7, 2010 21:32
Show Gist options
  • Select an option

  • Save bill-transue/569154 to your computer and use it in GitHub Desktop.

Select an option

Save bill-transue/569154 to your computer and use it in GitHub Desktop.
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
def back_facing
all(:conditions => {:orientation => "AB"})
end
def back_facing_grouped_by_elevation_index
front_facing.group_by{|component| component.elevation_index - component.component_model.height + 1}
end
def left_facing
all(:conditions => {:orientation => "AA"})
end
def left_facing_grouped_by_elevation_index
left_facing.group_by{|component| component.elevation_index - component.component_model.height + 1}
end
def right_facing
all(:conditions => {:orientation => "A"})
end
def right_facing_grouped_by_elevation_index
front_facing.group_by{|component| component.elevation_index - component.component_model.height + 1}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment