Just wondering how to dynamically name (say, in a loop) a series of instance variables. Something like this:
<% @current_issue.articles.each_with_index do |a, i| %>
<% i += 1 %>
<%= f.collection_select("article#{i}", @articles_hash1, :first, :last) %>
<% @articles1.each do |r| %>
<%= link_to(image_tag(r.image.url(:large)), r.image.url(:large), :id => 'article'+i.to_s+'_thumb'+r.id.to_s) %>
<% end %>
<% end %>
Where instead of @articles_hash1 it’d be @articles_hash[i]. I’m just not sure how to achieve that.
Cheers!
For anyone struggling with this, do yourself a favour and build an array of the instance variables in question, i.e.:
And then loop through that array, i.e.: