Rails counter available in collection partials
Rails makes a counter variable available within partials that are rendered with a collection. This variable follows the name of the collection. A @users
collection has a counter called user_counter
. The counter works like the index on an each loop. It counts the number of times a partial has been rendered. Let’s look at an example.