Erb, the template engine that you use in your views, has several different ways to embed ruby โโcode inside templates.
When you put the code inside the <%= %> blocks, erb evaluates the code inside and prints the value of the last statement in HTML. Since .each in ruby โโreturns the collection you completed, the loop using <%= %> tries to print a string representation of the entire array.
When you put code inside the <% %> %% <% %> blocks, erb just evaluates the code, rather than printing anything. This allows you to execute conditional statements, loops, or change variables in a view.
You can also remove puts from puts t . Erb knows how to try to convert the last value that he saw inside <%= %> into a string to display.
spike source share