ruby on rails - Correct number for each item in will_paginate list? -
i'm using will_paginate gem in rails app , loop through array of model instances rendered on page , limited 5 per page. before added will_paginate numbered each item simple <% += 1 %> of course went +1 each loop through array, , worked fine.
but i'm using will_paginate count restarts on each page, page 1 items go 1, 2, 3, 4, 5, , on second page starts over... 1, 2, 3, 4, 5
obviously isn't ideal. how count continue go previous pages?
i think following should work:
<% @collection.each_with_index |item, index| %> <%= @collection.offset + index + 1 %> ... <% end %>
Comments
Post a Comment