From ca16f01fd7476d9bdfa49050077149821bcd7f9f Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 20 Dec 2013 11:10:40 +0800 Subject: [PATCH] fix global paginate helper in application helper. --- app/controllers/application_controller.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8381170c..5535a0cd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -622,16 +622,12 @@ class ApplicationController < ActionController::Base ## Please added code in html. # def paginateHelper obj, pre_size=20 - # current_count = pre_size * (params['page'].to_i - 1) if params['page'].to_i > 0 - offset, limit = api_offset_and_limit({:limit => pre_size}) - objs_all = obj @obj_count = objs_all.count @obj_pages = Paginator.new @obj_count, limit, params['page'] - offset ||= @obj_pages.offset if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation - obj.offset(offset).limit(limit).all + obj.limit(@obj_pages.per_page).offset(@obj_pages.offset).all elsif obj.kind_of? Array - obj[offset..(offset+limit-1)] + obj[@obj_pages.offset, @obj_pages.per_page] else logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}" nil