I need to create a hash that has all of the objects of different product_id in arrays indexed by product_id as a key.
This gets close: fc.forecast_schedules.inject(Hash.new(0)) { |h, x| h[x.product_id] = ; h }
But the product_id in the hash only has the last forecast_schedule. I've tried things like this:
fc.forecast_schedules.inject(Hash.new(0)) { |h, x| h[x.product_id] << ; h }
But that gives me this error: TypeError: can't convert Array into Integer
How do I inform the hash key that holds something of the array instead of Integer....
-dustin