Use an each block to print the names of all the Zombie
-
12-11-2019 - |
Question
I'm trying to do the 'rails for zombies' course on codeschool, but I'm stuck on this one:
http://railsforzombies.org/levels/3/challenges/3
The frustrating thing about this course, is that you can't refine your answers, because you don't see the return value from incorrect solutions.
Anyway, the database looks like this:
id name graveyard
1 Ash Glen Haven Memorial Cemetary
2 Bob Chapel Hill Cemetary
3 Jim My Fathers Basement
The challenge is to "Use an each block to print the names of all the Zombies"
My solution is:
<%
zombies.each do |z|
puts z.name
end
%>
This fails, but I don't get to see how it fails, so I can't refine it. What is the solution?
Solution
Try this:
<% zombies.each do |z| %>
#note the equal-to sign below. this means that the text will be sent as output
<%= z.name %>
<% end %>
Notes:
puts
is used to output the text to the console<%= %>
is the way to output text in an ERB template
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow