Unless you’re using an older Ruby like 1.8 (I think this was added in 1.9 but I’m not sure), you can use each.with_index(1)
to get a 1-based enumerator:
In your case it would be like this:
<% @document.data.length.each.with_index(1) do |element, index| %>
...
<% end %>