Class: ActionView::Helpers::FormBuilder
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder
- Includes:
- AssetTagHelper, CaptureHelper, FormOptionsHelper, FormTagHelper, TagHelper
- Defined in:
- lib/facet_for/form_builder.rb
Instance Method Summary collapse
Instance Method Details
#facet_for(column, *args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/facet_for/form_builder.rb', line 8 def facet_for(column, *args) = args. facet_html = '' # Here, we collect information about the facet. What the user doesn't # supply, we'll make our best guess for. facet = { } facet[:object] = @object facet[:object_name] = @object_name # Information about the column. This is used to generate the default # label, and to pass the right selector to the Ransack fields. facet[:column_name] = column facet[:column_type] = [:column_type] facet[:includes] = [:includes] # This is the type of field we will render. If this isn't provided, we'll # determine this based on facet_column_type facet[:type] = [:type] # Did we pass in the params? Send it down to determine if we have a value. facet[:params] = [:params] # Did we pass in a default value? facet[:default] = [:default] # In the specific case of facet_type == :collection, we'll allow the user # to specify their own collection. If it's an association, we'll attempt # to provide one. facet[:collection] = [:collection] # Are we labeling it differently? facet[:label] = [:label] # How about adding a class? facet[:class] = [:class] @facet = FacetFor::Facet.new(facet) facet_html << @facet.render_facet facet_html.html_safe end |