instance method
fields_for_with_nested_attributes
Ruby on Rails 4.1.16
Since v3.0.20 PrivateSignature
fields_for_with_nested_attributes(association_name, association, options, block)
No documentation comment.
Parameters
-
association_namereq -
associationreq -
optionsreq -
blockreq
Source
# File actionview/lib/action_view/helpers/form_helper.rb, line 1830
def fields_for_with_nested_attributes(association_name, association, options, block)
name = "#{object_name}[#{association_name}_attributes]"
association = convert_to_model(association)
if association.respond_to?(:persisted?)
association = [association] if @object.send(association_name).respond_to?(:to_ary)
elsif !association.respond_to?(:to_ary)
association = @object.send(association_name)
end
if association.respond_to?(:to_ary)
explicit_child_index = options[:child_index]
output = ActiveSupport::SafeBuffer.new
association.each do |child|
options[:child_index] = nested_child_index(name) unless explicit_child_index
output << fields_for_nested_model("#{name}[#{options[:child_index]}]", child, options, block)
end
output
elsif association
fields_for_nested_model(name, association, options, block)
end
end
Defined in actionview/lib/action_view/helpers/form_helper.rb line 1830
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::FormBuilder