在罗列文章的时候,根据文章排序需要标注出文章的序号,这里不能用文章的id作为序号,因为一旦删除,则出现序号的错乱,同时文章的排序有时候是根据作者自定义的,因此这个序号是要随时变动的。

#一般结合paginate使用
#controller
@articles = Article.order("created_at desc").page(params[:page])
<% @words.each_with_index do |word, index| %>
  <tr>
    <td>
      <%= index+((params[:page] || 1).to_i - 1)*10+1 %><%= word.name %>
    </td>  
  </tr>
<% end -%>

results matching ""

    No results matching ""