增加应用列表页面的分页功能

This commit is contained in:
wanglinchun 2014-04-29 14:34:45 +08:00
parent 12ad20cf3b
commit 0403666cea
2 changed files with 13 additions and 5 deletions

View File

@ -7,7 +7,14 @@ class SoftapplicationsController < ApplicationController
# GET /softapplications.json
def index
@softapplications = Softapplication.all
@limit = 5
#new added
@softapplication_count = @softapplications.count
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
@offset ||= @softapplication_pages.offset
@softapplications = @softapplications[@offset,@limit]
#new added end
#@softapplications = @softapplications[@offset,@limit]
respond_to do |format|
format.html # index.html.erb
format.json { render json: @softapplications }

View File

@ -59,11 +59,12 @@
<% end %>
</div>
<div class="pagination"><%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
<div class="pagination">
<ul>
<div class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
<div class="pagination" style="float:left;">
<ul>
<%#= pagination_links_full @softapplications %>
</ul>
</div>
<% html_title l(:label_softapplication_list)%>