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] [x]; 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] <<
[x]; 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---