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 %>
精彩评论