Module: ActiveAdmin::Filters::FormtasticAddons
- Included in:
- FormBuilder, Inputs::FilterBase
- Defined in:
- lib/active_admin/filters/formtastic_addons.rb
Instance Method Summary collapse
-
#column ⇒ Object
An override to the built-in method, that respects Ransack.
-
#column_for(method) ⇒ Object
Returns the column for an attribute on the object being searched if it exists.
-
#humanized_method_name ⇒ Object
Returns the default label for a given attribute.
-
#klass ⇒ Object
The resource class, unwrapped from Ransack.
- #polymorphic_foreign_type?(method) ⇒ Boolean
-
#reflection_for(method) ⇒ Object
Returns the association reflection for the method if it exists.
Instance Method Details
#column ⇒ Object
An override to the built-in method, that respects Ransack. Since this is corrected, ‘column?` will also work.
30 31 32 |
# File 'lib/active_admin/filters/formtastic_addons.rb', line 30 def column column_for method end |
#column_for(method) ⇒ Object
Returns the column for an attribute on the object being searched if it exists.
24 25 26 |
# File 'lib/active_admin/filters/formtastic_addons.rb', line 24 def column_for(method) klass.columns_hash[method.to_s] if klass.respond_to? :columns_hash end |
#humanized_method_name ⇒ Object
Returns the default label for a given attribute. Uses ActiveModel I18n if available.
10 11 12 13 14 15 16 |
# File 'lib/active_admin/filters/formtastic_addons.rb', line 10 def humanized_method_name if klass.respond_to?(:human_attribute_name) klass.human_attribute_name(method) else method.to_s.send(builder.label_str_method) end end |
#klass ⇒ Object
The resource class, unwrapped from Ransack
39 40 41 |
# File 'lib/active_admin/filters/formtastic_addons.rb', line 39 def klass @object.object.klass end |
#polymorphic_foreign_type?(method) ⇒ Boolean
43 44 45 46 |
# File 'lib/active_admin/filters/formtastic_addons.rb', line 43 def polymorphic_foreign_type?(method) klass.reflections.values.select{ |r| r.macro == :belongs_to && r.[:polymorphic] } .map(&:foreign_type).include? method.to_s end |
#reflection_for(method) ⇒ Object
Returns the association reflection for the method if it exists
19 20 21 |
# File 'lib/active_admin/filters/formtastic_addons.rb', line 19 def reflection_for(method) klass.reflect_on_association(method) if klass.respond_to? :reflect_on_association end |