Module: ActiveAdmin::IndexHelper

Defined in:
app/helpers/active_admin/index_helper.rb

Instance Method Summary collapse

Instance Method Details

#batch_actions_to_displayObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/active_admin/index_helper.rb', line 13

def batch_actions_to_display
  @batch_actions_to_display ||= begin
    if active_admin_config && active_admin_config.batch_actions.any?
      active_admin_config.batch_actions.select do |batch_action|
        call_method_or_proc_on(self, batch_action.display_if_block)
      end
    else
      []
    end
  end
end

#collection_empty?(c = collection) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/helpers/active_admin/index_helper.rb', line 36

def collection_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



27
28
29
30
31
32
33
34
# File 'app/helpers/active_admin/index_helper.rb', line 27

def collection_size(c = collection)
  return c.count if c.is_a?(Array)
  return c.length if c.limit_value

  c = c.except :select, :order

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

#scope_name(scope) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/helpers/active_admin/index_helper.rb', line 4

def scope_name(scope)
  case scope.name
  when Proc then
    self.instance_exec(&scope.name).to_s
  else
    scope.name.to_s
  end
end