Module: Kaminari::ActiveRecordRelationMethods::InstanceMethods
- Defined in:
- lib/kaminari/models/active_record_relation_methods.rb
Instance Method Summary collapse
-
#count(column_name = nil, options = {}) ⇒ Object
:nodoc:.
- #size ⇒ Object
-
#total_count ⇒ Object
:nodoc:.
Instance Method Details
#count(column_name = nil, options = {}) ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/kaminari/models/active_record_relation_methods.rb', line 8 def count #:nodoc: limit_value ? length : super end |
#size ⇒ Object
25 26 27 |
# File 'lib/kaminari/models/active_record_relation_methods.rb', line 25 def size [[0,(total_count - (current_page - 1) * limit_value)].max, limit_value].min 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(nil, {:dont_use_kaminari => true}) c.respond_to?(:count) ? c.count : c end |