Giles Bowkett wrote:

> 
> Instead of
> 
> arbitrary_class = [item, other_item]
> 
> And then a whole bunch of "meta" stuff, including an eval on the class
> name - which you have to create an array of strings to do anyway - I
> would recommend maybe this:
> 
> classes_with_items = {"ArbitraryClass" => ["item", "other_item"]}
> 
> and then
> 
> classes_with_items.each do |class_name, array|
>   array.each do |item_name|
>     class_name.constantize.new(:item_name => item_name)
>   end
> end

This worked beautifully! love the solution.

Just for fun, I used:

  Object.const_get(class_name).create(:item_name => item_name)

Note how i had to use .create instead of .new... This probably has to do 
with Rails, so I'll take it to the Rails forum. But this has really 
straightened out my understanding of Ruby's nested arrays, hashes, and 
blocks.... Thank you!
-- 
Posted via http://www.ruby-forum.com/.