I want to routinely make updated hashes in controller methods and use the data in views. Can I put this in a method and be done? my_hash = {} widget_holder = Cars.find(:all) my_hash = widget_holder.map { |widget| widget.parking_spot_number, widget.name} Is that it? Is an array of two element arrays a hash or is there another step? I know I''ve seen this done but i cant find it in my books or via search. Can I then go: <%=h my_hash[36] %> in a table slot and get it to return " Blue Cadillac Eldorado" if the instance of Car had values for name(Blue Cadillac Eldorado) and parking spot(36) accordingly? Am I missing a step? (or two?) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok I stunk that one up and to boot, the question had recently been answered. (sorry i didnt look hard enough) Here is the link to the answer(elsewhere on this forum) http://www.ruby-forum.com/topic/129491#new While what I put forward didn''t even return an array, I am curious about one issue. Is an array of strings that looks like a hash a hash? Could you go x = value + " => " + value @existing_hash << x If so, could i use map like this? new_hash = object_collection.map{|object| object.key_attribute + " =>" + object.value_attribute } -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---