Class: ActiveAdmin::Inputs::FilterSelectInput
- Inherits:
-
Formtastic::Inputs::SelectInput
- Object
- Formtastic::Inputs::SelectInput
- ActiveAdmin::Inputs::FilterSelectInput
- Includes:
- FilterBase
- Defined in:
- lib/active_admin/inputs/filter_select_input.rb
Instance Method Summary collapse
-
#collection ⇒ Object
Provides an efficient default lookup query if the attribute is a DB column.
-
#input_html_options_name ⇒ Object
was “#object_name”.
-
#input_name ⇒ Object
When it’s a HABTM or has_many association, Formtastic builds “object_ids”.
-
#input_options ⇒ Object
Include the “Any” option if it’s a dropdown, but not if it’s a multi-select.
-
#multiple_by_association? ⇒ Boolean
Would normally return true for has_many and HABTM, which would subsequently cause the select field to be multi-select instead of a dropdown.
- #pluck_column ⇒ Object
Methods included from FilterBase
#collection_from_options, #input_wrapping, #required?, #wrapper_html_options
Methods included from Filters::FormtasticAddons
#column, #column_for, #humanized_method_name, #klass, #polymorphic_foreign_type?, #reflection_for
Instance Method Details
#collection ⇒ Object
Provides an efficient default lookup query if the attribute is a DB column.
31 32 33 34 35 36 37 |
# File 'lib/active_admin/inputs/filter_select_input.rb', line 31 def collection if ![:collection] && column pluck_column else super end end |
#input_html_options_name ⇒ Object
was “#object_name”
20 21 22 |
# File 'lib/active_admin/inputs/filter_select_input.rb', line 20 def "#{object_name}[#{input_name}]" end |
#input_name ⇒ Object
When it’s a HABTM or has_many association, Formtastic builds “object_ids”. That doesn’t fit our scenario, so we override it here.
8 9 10 11 12 |
# File 'lib/active_admin/inputs/filter_select_input.rb', line 8 def input_name name = method.to_s name.concat '_id' if reflection name.concat multiple? ? '_in' : '_eq' end |
#input_options ⇒ Object
Include the “Any” option if it’s a dropdown, but not if it’s a multi-select.
15 16 17 |
# File 'lib/active_admin/inputs/filter_select_input.rb', line 15 def super.merge :include_blank => multiple? ? false : I18n.t('active_admin.any') end |
#multiple_by_association? ⇒ Boolean
Would normally return true for has_many and HABTM, which would subsequently cause the select field to be multi-select instead of a dropdown.
26 27 28 |
# File 'lib/active_admin/inputs/filter_select_input.rb', line 26 def multiple_by_association? false end |
#pluck_column ⇒ Object
39 40 41 |
# File 'lib/active_admin/inputs/filter_select_input.rb', line 39 def pluck_column klass.reorder("#{method} asc").uniq.pluck method end |