Module: Kaminari::ActiveRecordRelationMethods::InstanceMethods
- Defined in:
- lib/kaminari/models/active_record_relation_methods.rb
Instance Method Summary collapse
-
#count ⇒ Object
:nodoc:.
-
#total_count ⇒ Object
:nodoc:.
Instance Method Details
#count ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/kaminari/models/active_record_relation_methods.rb', line 8 def count #:nodoc: limit_value ? length : super end |
#total_count ⇒ Object
:nodoc:
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kaminari/models/active_record_relation_methods.rb', line 13 def total_count #:nodoc: # #count overrides the #select which could include generated columns referenced in #order, so skip #order here, where it's irrelevant to the result anyway c = except(:offset, :limit, :order) # a workaround for 3.1.beta1 bug. see: https://github.com/rails/rails/issues/406 c = c.reorder nil # Remove includes only if they are irrelevant c = c.except(:includes) unless references_eager_loaded_tables? # .group returns an OrderdHash that responds to #count c = c.count c.respond_to?(:count) ? c.count : c end |