mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
don't load all records when counting without limiting (thanks to @ankane)
this fixes serious performance regression introduced in 0.11.0.
This commit is contained in:
parent
91d6628360
commit
ca38024f39
1 changed files with 2 additions and 1 deletions
|
@ -3,9 +3,10 @@ module Kaminari
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
# a workaround for AR 3.0.x that returns 0 for #count when page > 1
|
# a workaround for AR 3.0.x that returns 0 for #count when page > 1
|
||||||
|
# if +limit_value+ is specified, load all the records and count them
|
||||||
if Rails.version < '3.1'
|
if Rails.version < '3.1'
|
||||||
def count #:nodoc:
|
def count #:nodoc:
|
||||||
limit_value == 0 ? 0 : length
|
limit_value ? length : super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue