Skip to content

Instantly share code, notes, and snippets.

@lawrencecurtis
Created November 11, 2009 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lawrencecurtis/232126 to your computer and use it in GitHub Desktop.
Save lawrencecurtis/232126 to your computer and use it in GitHub Desktop.
# used to make a LOT of data nice and easy to loop through in the view
orders = orders.group_by(&:ItemCode)
orders.each do |key, order|
orders[key] = order.group_by(&:year)
orders[key].each do |k, year|
orders[key][k] = year.group_by(&:month)
total = 0
orders[key][k].each do |m, data|
total +=data[0].quantity.to_f
orders[key][k][m] = data[0].quantity
end
orders[key][k]['total'] = total
end
end
orders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment