开发者

rails 3: how to output the content of a array

开发者 https://www.devze.com 2023-01-29 18:30 出处:网络
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:

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

精彩评论

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