don't count error_reports rows for ui pagination

Change-Id: Ib1589495a507aeb00d8986f6e079062ff90da241
Reviewed-on: https://gerrit.instructure.com/4368
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Brian Palmer 2011-06-24 09:08:40 -06:00
parent 774a5d7735
commit 2ed68acc2e
2 changed files with 17 additions and 2 deletions

View File

@ -17,8 +17,11 @@
#
class ErrorsController < ApplicationController
PER_PAGE = 20
before_filter :require_user, :require_site_admin
def index
params[:page] = params[:page].to_i > 0 ? params[:page].to_i : 1
@reports = ErrorReport
@message = params[:message]
@ -31,7 +34,7 @@ class ErrorsController < ApplicationController
@reports = @reports.scoped(:conditions => { :category => params[:category] })
end
@reports = @reports.paginate(:page => params[:page], :per_page => 25, :order => 'id DESC')
@reports = @reports.all(:limit => PER_PAGE, :offset => ((params[:page]-1)*PER_PAGE), :order => 'id DESC')
end
def show
@reports = WillPaginate::Collection.new(1, 1, 1)

View File

@ -12,7 +12,17 @@
<button type="submit" class="button"><%= t "#buttons.search", "Search" %></button>
<% end %>
<%= will_paginate(@reports) %>
<% content_for :pagination do %>
<div class='pagination'>
<% if params[:page] > 1 %>
<%= link_to('< Prev', params.merge(:page => (params[:page] - 1))) %>
<% end %>
<%= link_to('Next >', params.merge(:page => (params[:page] + 1))) %>
</div>
<% end %>
<%= yield :pagination %>
<% @reports.each do |report| %>
<div style="margin-bottom: 20px;">
<h3>
@ -40,3 +50,5 @@
</div>
</div>
<% end %>
<%= yield :pagination %>