Sha256: b22cd176e89f457ef72776ab365385d03dd61c1a7bf82320be9f0145eba41e11
Contents?: true
Size: 1.2 KB
Versions: 5
Compression:
Stored size: 1.2 KB
Contents
ActionView::Helpers::FormHelper.class_eval do private # This trick makes it possible to use the record_collection object # directly in to forms and point to the proper controller action # like: # = form_for @collection do |f| # = f.text_field :name alias_method :old_apply_form_for_options!, :apply_form_for_options! def apply_form_for_options!(record, object, options) #:nodoc: if record.is_a?(RecordCollection::Base) object = convert_to_model(object) as = options[:as] namespace = options[:namespace] action, method = [:collection_update, :post] options[:html].reverse_merge!( class: as ? "#{action}_#{as}" : dom_class(object, action), id: (as ? [namespace, action, as] : [namespace, dom_id(object, action)]).compact.join("_").presence, method: method ) options[:url] ||= if options.key?(:format) polymorphic_path([action, record], format: options.delete(:format)) else polymorphic_path([action, record], {}) end else old_apply_form_for_options!(record, object, options) end end end
Version data entries
5 entries across 5 versions & 1 rubygems