Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails 3: how to output the content of a array

Im updating to rails 3 and experience the problem of writing the content of a array to a html view. If I just place the array like:

<%= array %>

It gets now outputed as:

["...","...","..."]

with rails 2 it was just the content which got printed...

Any Ideas?

Markus

like image 531
Markus Avatar asked Nov 22 '25 09:11

Markus


2 Answers

<%= array.join ' ' %> 
like image 79
Doon Avatar answered Nov 24 '25 21:11

Doon


You can try using array#to_sentence method:

<%= array.to_sentence %>

Or just a join:

<%= array.join(", ") %>

Depends on how you want the output to look.

like image 34
markquezada Avatar answered Nov 24 '25 23:11

markquezada