Jeremy Smith
Jeremy Smith

Reputation: 15069

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 the unchanged array. Why is this?

Upvotes: 0

Views: 247

Answers (2)

DGM
DGM

Reputation: 26979

Alternately you might try collect

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

Upvotes: 0

mbreining
mbreining

Reputation: 7809

Try this:

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

Upvotes: 2

Related Questions