Sha256: b23b0e26fdccb03fad256bc02f522c6e725ad7721eea4f98386feb5a34133e72
Contents?: true
Size: 1.06 KB
Versions: 37
Compression:
Stored size: 1.06 KB
Contents
class CustomFormBuilder < SimpleForm::FormBuilder def initialize(*) super end def association(association, options = {}, &block) resolve_custom_input_association(association, options) super(association, options, &block) end def resolve_custom_input_association(association, options) return if options[: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? options[:as] = key break end end private def fetch_association_collection(reflection, options) options_method = "options_for_#{reflection.name}".to_sym if object.respond_to?(options_method) then options.fetch(:collection) do object.send(options_method) end else super(reflection, options) end end end
Version data entries
37 entries across 37 versions & 1 rubygems