Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Stefan Piatkov14,312 Points
Now we need to output HTML <p> elements with the name attribute of each pet. Within the each block, add <p></p> HTML tag
Not sure where I'm wrong.. If someone could please explain why I was wrong it'd be greatly appreciated.
<% @pets.each do |name| %> <p> <%= pet.name %> </p> <% end %>
Jay McGavrenTreehouse Teacher
The name you used for your
each block's parameter doesn't match the name of the variable you're accessing within the
<!-- The next line stores each pet in a variable called "name" --> <% @pets.each do |name| %> <p> <!-- The next line accesses a nonexistent variable called "pet" --> <%= pet.name %> </p> <% end %>
Change it to
@pets.each do |pet|, and it should work.
If you haven't already done our Ruby Loops course, you may find some helpful info here.