Class: CustomFormBuilder
- Inherits:
-
SimpleForm::FormBuilder
- Object
- SimpleForm::FormBuilder
- CustomFormBuilder
- Defined in:
- app/inputs/custom_form_builder.rb
Instance Method Summary collapse
- #association(association, options = {}, &block) ⇒ Object
-
#initialize ⇒ CustomFormBuilder
constructor
A new instance of CustomFormBuilder.
- #resolve_custom_input_association(association, options) ⇒ Object
Constructor Details
#initialize ⇒ CustomFormBuilder
Returns a new instance of CustomFormBuilder.
2 3 4 |
# File 'app/inputs/custom_form_builder.rb', line 2 def initialize(*) super end |
Instance Method Details
#association(association, options = {}, &block) ⇒ Object
6 7 8 9 |
# File 'app/inputs/custom_form_builder.rb', line 6 def association(association, = {}, &block) resolve_custom_input_association(association, ) super(association, , &block) end |
#resolve_custom_input_association(association, options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/inputs/custom_form_builder.rb', line 11 def resolve_custom_input_association(association, ) return if [:as].present? [ "#{object.class.name.demodulize.underscore}_#{association.to_s}".to_sym, association ].each do |key| camelized = "#{key.to_s.camelize}Input" mapping = attempt_mapping_with_custom_namespace(camelized) || attempt_mapping(camelized, Object) || attempt_mapping(camelized, self.class) next unless mapping.present? [:as] = key break end end |