config/initializers/core_extensions_2.rb
# expects an array of objects
# will create a new array where $attribute is unique by taking the first instance and deleting the rest
# mimics some of what the MySQL GROUP BY does
expects an array of objects
will create a new array where $attribute is unique by taking the first instance and deleting the rest
mimics some of what the MySQL GROUP BY does
expects an array of objects will create a new array where $attribute is unique by taking the first instance and deleting the rest mimics some of what the MySQL GROUP BY does
def group_objects_by(attribute)
    grouped_array = []
    used_values = {}
    self.each do |obj|
      value = obj.send(attribute.to_sym)
      grouped_array << obj if used_values[value].blank?
      used_values[value] = true
    end
    grouped_array
  end
def group_objects_by ( attribute ) grouped_array = [ ] used_values = { } self . each do | obj | value = obj . send ( attribute . to_sym ) grouped_array << obj if used_values [ value ] . blank? used_values [ value ] = true end grouped_array end
expects an array of objects
will create a new array where $attribute is unique by taking the first instance and deleting the rest
mimics some of what the MySQL GROUP BY does
expects an array of objects will create a new array where $attribute is unique by taking the first instance and deleting the rest mimics some of what the MySQL GROUP BY does
attribute
<not_specific>