This is simple but I can't find anything. I have an array that I want to loop through, pull up a specific attribute for each, and then store those attributes in a new array.
Basically:
- store
array2 = [Array1[0].attr, Array1[2].attr, Array1[3].attr]
What I have
<% storedArray = [] %>
<% @data = current_user.data_items %>
<% @data.each do |data_item| %>
<% storedArray[data_item.count] = data_item.url_metric.da %>
<% end %>
Updated:
I got it to work but in a really bad way. Suggestions?
<% array = []; i = 0 %>
<% @data = current_user.reports[0].data_items %>
<% @data.each do |data_item| %>
<% array[i] = data_item.url_metric.da %>
<% i = i+1 %>
<% end %>
<%= array %>