Module: ActiveAdmin::Helpers::Collection

Included in:
Views::IndexList, Views::Pages::Index, Views::PaginatedCollection, Views::Scopes
Defined in:
lib/active_admin/helpers/collection.rb

Instance Method Summary collapse

Instance Method Details

#collection_is_empty?(c = collection) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/active_admin/helpers/collection.rb', line 12

def collection_is_empty?(c = collection)
  collection_size(c) == 0
end

#collection_size(c = collection) ⇒ Object

  1. removes `select` and `order` to prevent invalid SQL

  2. correctly handles the Hash returned when `group by` is used


6
7
8
9
10
# File 'lib/active_admin/helpers/collection.rb', line 6

def collection_size(c = collection)
  c = c.except :select, :order

  c.group_values.present? ? c.count.count : c.count
end