Ah, I copied and pasted your inspect output and assigned it to a
variable, and Rails recreated it as a hash, so it worked when I tried
it.

Glad you came right.

On Aug 27, 10:20 am, Zack Nathan <li...@ruby-forum.com> wrote:
> Colin Law wrote:
> > On 27 August 2010 08:33, Zack Nathan <li...@ruby-forum.com> 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 viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to