rails_pagination 2.0.7 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,16 @@ module RailsPagination
3
3
  module Base
4
4
 
5
5
  def inherited(subclass)
6
- if subclass.superclass == ::ActiveRecord::Base
7
- subclass.scope :page, Proc.new {|number|
8
- subclass.limit(subclass.default_per_page).offset(subclass.default_per_page * ([number.to_i, 1].max - 1))
9
- } do
10
- include RailsPagination::ActiveRecord::Relation
6
+ subclass.class_eval do
7
+ if superclass == ::ActiveRecord::Base
8
+ scope :page, Proc.new { |number|
9
+ limit(default_per_page).offset(default_per_page * ([number.to_i, 1].max - 1))
10
+ } do
11
+ include RailsPagination::ActiveRecord::Relation
12
+ end
11
13
  end
12
- end
14
+ end
15
+ super
13
16
  end
14
17
 
15
18
  def default_per_page(value=nil)
@@ -17,8 +17,7 @@ module RailsPagination
17
17
  @total_count ||= begin
18
18
  c = except(:offset, :limit, :order)
19
19
  c = c.except(:includes) unless references_eager_loaded_tables?
20
- uses_distinct_sql_statement = c.to_sql =~ /DISTINCT/i
21
- if uses_distinct_sql_statement
20
+ if c.to_sql =~ /DISTINCT/i
22
21
  c.length
23
22
  else
24
23
  c = c.count
@@ -1,5 +1,5 @@
1
1
  module RailsPagination
2
2
 
3
- VERSION = '2.0.7'
3
+ VERSION = '2.0.8'
4
4
 
5
5
  end