How do I add a counter to an .each loop? Is there any easy way of doing this?
I tried the below, but it does not seem to work.
<% @album.each do |e| %>
<%= e %> #my_counter_does_not_work :)
<%= link_to e.name, :controller => "images", :action => "album", :album_id => e.id, :album_name => e.name %>
<% end %>
Use
each_with_index: the index will automatically be your counter (but note it starts at 0 and not 1):