开发者

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


<%= array.join ' ' %> 


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.


If it's for debugging purposes, why not try:

<%= debug array %>

if you need to present the array in a specific way, you're better off iterating the array and presenting each element with a repeatable block or a partial.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜