user5853457
user5853457

Reputation:

n.times do returns value of n

I have a problem with my code, I want it to display n number of stars. It display the right number of stars, plus the integer like ***3I only want ***

show.html.slim

= article.rating_average.times do
  span
  i.fa.fa-star

Upvotes: 0

Views: 89

Answers (1)

Andrey Deineko
Andrey Deineko

Reputation: 52357

Change = to -:

- article.rating_average.times do
  %span.fa.fa-star
  • = evaluates code and prints the returned value (3 is a return value of article.rating_average.times {})
  • - just evaluates code (gives you 3 stars without the returned value printed)

Upvotes: 1

Related Questions