On the HTML display side, for example
A code used when numbering so that the numerical value changes depending on the content. (It was at such times that it was used most often)
By using this, the value at the start of numbering can be started from the value in parentheses.
You don't have to write + 1
.
<% ....map.with_index(1) do |a, i| %>
<p><%= i %></p>
each.with_index
In this case, it will start with 0
, so you need to write + 1
.
<% ....map.each_with_index do |a, i| %>
<p><%= i + 1 %></p>
Recommended Posts