Class: ActiveAdmin::Inputs::Filters::SelectInput
- Inherits:
-
Formtastic::Inputs::SelectInput
- Object
- Formtastic::Inputs::SelectInput
- ActiveAdmin::Inputs::Filters::SelectInput
- Includes:
- Base
- Defined in:
- lib/active_admin/inputs/filters/select_input.rb
Instance Method Summary collapse
-
#collection ⇒ Object
Provides an efficient default lookup query if the attribute is a DB column.
-
#include_blank ⇒ Object
Provide the AA translation to the blank input field.
- #input_html_options_name ⇒ Object
- #input_name ⇒ Object
-
#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
- #reflection_searchable? ⇒ Boolean
- #searchable_method_name ⇒ Object
Methods included from Base
#collection_from_options, #input_wrapping, #label_from_options, #required?, #wrapper_html_options
Methods included from Filters::FormtasticAddons
#column, #column_for, #has_predicate?, #humanized_method_name, #klass, #polymorphic_foreign_type?, #reflection_for, #scope?, #searchable_has_many_through?, #seems_searchable?
Methods included from Formtastic::Inputs::Base
Instance Method Details
#collection ⇒ Object
Provides an efficient default lookup query if the attribute is a DB column.
40 41 42 43 44 45 46 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 40 def collection if ![:collection] && column pluck_column else super end end |
#include_blank ⇒ Object
Provide the AA translation to the blank input field.
25 26 27 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 25 def include_blank I18n.t "active_admin.any" if super end |
#input_html_options_name ⇒ Object
29 30 31 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 29 def "#{object_name}[#{input_name}]" # was "#{object_name}[#{association_primary_key}]" end |
#input_name ⇒ Object
8 9 10 11 12 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 8 def input_name return method if seems_searchable? searchable_method_name + (multiple? ? "_in" : "_eq") 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.
35 36 37 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 35 def multiple_by_association? false end |
#pluck_column ⇒ Object
48 49 50 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 48 def pluck_column klass.reorder("#{method} asc").distinct.pluck method end |
#reflection_searchable? ⇒ Boolean
52 53 54 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 52 def reflection_searchable? reflection && !reflection.polymorphic? end |
#searchable_method_name ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/active_admin/inputs/filters/select_input.rb', line 14 def searchable_method_name if searchable_has_many_through? "#{reflection.through_reflection.name}_#{reflection.foreign_key}" else name = method.to_s name.concat "_#{reflection.association_primary_key}" if reflection_searchable? name end end |