class ActiveAdmin::Inputs::FilterSelectInput
Public Instance Methods
collection()
click to toggle source
Provides an efficient default lookup query if the attribute is a DB column.
Calls superclass method
# File lib/active_admin/inputs/filter_select_input.rb, line 31 def collection if !options[:collection] && column pluck_column else super end end
input_html_options_name()
click to toggle source
was “#object_name”
# File lib/active_admin/inputs/filter_select_input.rb, line 20 def input_html_options_name "#{object_name}[#{input_name}]" end
input_name()
click to toggle source
When it's a HABTM or has_many association, Formtastic builds “object_ids”. That doesn't fit our scenario, so we override it here.
# 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()
click to toggle source
Include the “Any” option if it's a dropdown, but not if it's a multi-select.
Calls superclass method
# File lib/active_admin/inputs/filter_select_input.rb, line 15 def input_options super.merge :include_blank => multiple? ? false : I18n.t('active_admin.any') end
multiple_by_association?()
click to toggle source
Would normally return true for has_many and HABTM, which would subsequently cause the select field to be multi-select instead of a dropdown.
# File lib/active_admin/inputs/filter_select_input.rb, line 26 def multiple_by_association? false end
pluck_column()
click to toggle source
# File lib/active_admin/inputs/filter_select_input.rb, line 39 def pluck_column klass.reorder("#{method} asc").uniq.pluck method end