Sha256: 7271eeeb7ee4dd2cb24f88df40820c13dc7b7b6bd9804585dc3beb436afc6f17

Contents?: true

Size: 490 Bytes

Versions: 42

Compression:

Stored size: 490 Bytes

Contents

module ActiveAdmin
  module Helpers
    module Collection
      # 1. removes `select` and `order` to prevent invalid SQL
      # 2. correctly handles the Hash returned when `group by` is used
      def collection_size(c = collection)
        return c.count if c.is_a?(Array)

        c = c.except :select, :order

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

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

Version data entries

42 entries across 42 versions & 5 rubygems

Version Path
activeadmin-1.0.0 lib/active_admin/helpers/collection.rb
activeadmin-1.0.0.pre5 lib/active_admin/helpers/collection.rb