I have a simple page that displays some ‘Games’.
Heres the code:
<ul>
<%= @tvshow.games.each do |game| %>
<li><%= game.gameTitle %></li>
<% end %>
</ul>
It displays like this:
The All-Syrup Squishee
#<Game:0xb6783820>
With the #Game tag coming AFTER the list item but before the closing list tag. Any idea why it’s showing up or how I could get rid of it?
<%=outputs the result as markup, in this case an instance of the Game class.For this kind of loop you want to use
<%which executes some code but does not produce markup.Edit line 2 to read
<% @tvshow.games.each do |game| %>