Printing elements of array using ERB
Posted
by
Keva161
on Stack Overflow
See other posts from Stack Overflow
or by Keva161
Published on 2012-11-04T14:39:32Z
Indexed on
2012/11/04
17:01 UTC
Read the original article
Hit count: 258
I'm trying to print a simple array defined in my controller into my view with a new line for each element. But what it's doing is printing the whole array on one line.
Here's my controller:
class TodosController < ApplicationController
def index
@todo_array = [ "Buy Milk", "Buy Soap", "Pay bill", "Draw Money" ]
end
end
Here's my view:
<%= @todo_array.each do |t| %>
<%= puts t %><\br>
<% end %>
Here's the result:
<\br> <\br> <\br> <\br> ["Buy Milk", "Buy Soap", "Pay bill", "Draw Money"]
© Stack Overflow or respective owner