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-rails-1.7.1 lib/active_admin/helpers/collection.rb
activeadmin-rails-1.7.0 lib/active_admin/helpers/collection.rb
activeadmin-rb-1.6.0 lib/active_admin/helpers/collection.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/lib/active_admin/helpers/collection.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/lib/active_admin/helpers/collection.rb
activeadmin-rb-1.5.2 lib/active_admin/helpers/collection.rb
activeadmin-2.9.0 lib/active_admin/helpers/collection.rb
activeadmin-2.8.1 lib/active_admin/helpers/collection.rb
activeadmin-2.8.0 lib/active_admin/helpers/collection.rb
activeadmin-rb-1.5.1 lib/active_admin/helpers/collection.rb
activeadmin-2.7.0 lib/active_admin/helpers/collection.rb
activeadmin-2.6.1 lib/active_admin/helpers/collection.rb
activeadmin-2.6.0 lib/active_admin/helpers/collection.rb
activeadmin-2.5.0 lib/active_admin/helpers/collection.rb
activeadmin-2.4.0 lib/active_admin/helpers/collection.rb
activeadmin-2.3.1 lib/active_admin/helpers/collection.rb
activeadmin-2.3.0 lib/active_admin/helpers/collection.rb
activeadmin-2.2.0 lib/active_admin/helpers/collection.rb
activeadmin-2.1.0 lib/active_admin/helpers/collection.rb
activeadmin-2.0.0 lib/active_admin/helpers/collection.rb