# Nested each loops

**URL:** <https://www.ruby-forum.com/t/nested-each-loops/174673>\
**Category:** Rails\
**Created:** [August 31, 2009, 10:45am UTC](https://www.ruby-forum.com/t/nested-each-loops/174673 "2009-08-31T10:45:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [August 31, 2009, 10:45am UTC](https://www.ruby-forum.com/t/nested-each-loops/174673/1 "2009-08-31T10:45:30Z")

</div>

Hey,

_sorry for double post_  
So I keep getting “undefined method `each’ for #\<Definition:  
0x28fa154\>”. The call that gets made returns 1 word object with 2  
definition objects. I can verify both definition objects get returned  
with all there attributes because I can output data like this:

\<% @word.definitions.each do |h| %\>

\<%=h h.definition %\>

  

\<%=h h.id %\>

  
\<% end %\>

But I’d like to not write out every definition attribute so I attempt  
to loop those as well like this:

\<% @word.definitions.each do |h| %\>  
\<% h.each do |i| %\>

\<%=h h.i %\>

  
\<% end %\>  
\<% end %\>

But get the above mentioned error. My guess is I’m getting a returned  
data type that is not an array? So I can’t loop them the same way?  
Your suggestions would be very helpful, thanks.
