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
- #collection_is_empty?(collection = collection) ⇒ Boolean
-
#collection_size(collection = collection) ⇒ Object
Works around this issue: github.com/rails/rails/issues/7121.
Instance Method Details
#collection_is_empty?(collection = collection) ⇒ Boolean
18 19 20 |
# File 'lib/active_admin/helpers/collection.rb', line 18 def collection_is_empty?(collection=collection) collection_size(collection) == 0 end |
#collection_size(collection = collection) ⇒ Object
Works around this issue: github.com/rails/rails/issues/7121
GROUP BY + COUNT drops SELECT statement. This leads to SQL error when the ORDER statement mentions a column defined in the SELECT statement.
We remove the ORDER statement to work around this issue.
10 11 12 13 14 15 16 |
# File 'lib/active_admin/helpers/collection.rb', line 10 def collection_size(collection=collection) size = collection.reorder("").count # when GROUP BY is used, AR returns Hash instead of Fixnum for .size size = size.size if size.kind_of?(Hash) size end |