I have a table and paginated to 20 per page:
<% @num = 0%>
<table>
<tr>
<th>id</th>
<th>title</th>
</tr>
<% for authors in @authors%>
<tr>
<td><%= @num += 1 %></td>
<td><%= authors.title %></td>
</tr>
<% end %>
</table>
<%= will_paginate @authors%>
I would like to make the id row to be continues. When I click on 1nd page i should see 1,2 3, 4 etc id. And when I click 2nd page I should see 21, 22, 23 etc but it just restarted to 1, 2 3
Instead of initializing
@numto 0, set it toWhen you do
What you get back is a
WillPaginate::Collection. This is a subclass of Array, with methods such as the total number of pages, the number of items per page etc. In particular,offsetgives the offset of the current page.