Hi -

What is the best way to create a nested hash from an array of objects?

Here's what I'm trying to do, take my array of objects and use the
attribute 'position' as a key for each nested hash.  The nested hash
will contain the other array attributes.

Example:

[#<Spec id: 4057, position: 1, name: "Tonnage", english_unit: "T",
metric_unit: "t">,
[#<Spec id: 4058, position: 2, name: "Spindle", english_unit: "T",
metric_unit: "t">]


This is what I want to end up with from the above:

{1 => {:name => "Tonnage", :english_unit => "T", :metric_unit => "t"},
2 => {:name => "Spindle", :english_unit => "T", :metric_unit => "t"}}

I've tried different methods of enumerating but can't quite get what I
want.

Thanks for any help!
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to