开发者

I'm attempting to render an array as a series of links

I'm trying to do this in a view file:

<td><%= obj.user_ids.values.each {|user_id| link_to results_path(user_id)} %></td>

But it is displayed as开发者_StackOverflow社区 the unchanged array. Why is this?


Try this:

<td>
  <% obj.user_ids.values.each do |user_id| -%>
    <%= link_to results_path(user_id) %>
  <% end -%>
</td>


Alternately you might try collect

<%= obj.user_ids.values.collect {|user_id| link_to results_path(user_id)}.join %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜