I want to use nhl_scores gem to get and display recent NHL game scores on the page. This is how I defined the method in app/helpers/application_helper.rb:
def scores
games = NHLScores::Games.new
s = []
games.recent.each do |g|
s.push("#{g.away_team} @ #{g.home_team} - #{g.away_team_score}:#{g.home_team_score}")
end
s
end
And this is how I display this array:
<ul>
<%= scores.each do |s| %>
<li><%= s %></li>
<% end %>
</ul>
The result is:
Yeah, for some reason the full array gets displayed after the last closing li tag but before the closing ul tag. How do I remove it? Should I define the method that returns this array elsewhere?
Try this
The
<%= %>
is displaying the entire scores array again which you dont want(<%= %>
causes the value to be displayed).