Ruby on rails 将为增量表id分页
我有一张表格,每页页码为20:Ruby on rails 将为增量表id分页,ruby-on-rails,Ruby On Rails,我有一张表格,每页页码为20: <% @num = 0%> <table> <tr> <th>id</th> <th>title</th> </tr> <% for authors in @authors%> <tr> <td><%= @num += 1 %><
<% @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%>
身份证件
标题
我想让id行继续。当我单击第1页时,我会看到1,2 3,4等id。当我单击第2页时,我会看到21,22,23等,但它只是重新启动到1,2 3,而不是将
@num
初始化为0,将其设置为
@authors.offset
当你这样做的时候
@authors = Author.paginate(...)
您得到的是一个
WillPaginate::集合
。这是数组的一个子类,具有诸如总页数、每页项目数等方法。特别是,offset
给出当前页的偏移量 谢谢,我试试看。我正在使用rails 2.3如何计算@authors的总数?还有一个total_entries属性