Colin Law wrote:
> On 27 August 2010 08:33, Zack Nathan <[email protected]> wrote:
>> Here is what the hash looks like:
>> @parsed_response={"food"=>{"name"=>"Chicken: Breast Quarters,
> 
> I presume this is actually @information rather than @parsed_response
> (or the other way around).
> 
>> rotisserie, no skin or wing (Boston Market)",
>> "id"=>"42e5699f-79cd-436c-965b-90850b26a278",
>> "servings"=>{"serving"=>[{"name"=>"serving (4.9 oz)",
> 
> serving is an array (the square bracket is a giveaway) so you must use
> an integer to index it not 'name' as you are doing.  You can do
> serving[0]['name'] or use serving.each
> 
> Colin

So like this?
  <% @information['food']['servings'].each do |servings| %>
  <% servings['serving'].each do |serving| %>
    <% serving.each do |s| %>
    <% portions << s['name'] %>
    <%= s['name'] %>
    <br/>
    <% end %>
  <% end %>

Thankyou
-- 
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 [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