In my .erb, I have a simple each loop:
<%= @user.settings.each do |s| %>
..
<% end %>
What is the simplest way to check if it’s currently going through its first iteration? I know I could set i=0...i++ but that is just too messy inside of an .erb. Any suggestions?
It depends on the size of your array. If it is really huge (couple of hundreds or more), you should
.shiftthe first element of the array, treat it and then display the collection:Or you can use
.each_with_index: