Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Allow for multiple blueprints for the same association #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/nested_form/builder_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def link_to_add(*args, &block)

options[:class] = [options[:class], "add_nested_fields"].compact.join(" ")
options["data-association"] = association
options["data-blueprint-id"] = fields_blueprint_id = fields_blueprint_id_for(association)
options["data-blueprint-id"] = fields_blueprint_id = fields_blueprint_id_for(options[:blueprint] || association)
args << (options.delete(:href) || "javascript:void(0)")
args << options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 41 needs to be

block, options = @fields[fields_blueprint_id_for(association)].values_at(:block, :options)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those options not going to be associated with the custom blueprint name when it is set?

Expand Down Expand Up @@ -83,7 +83,7 @@ def fields_for_with_nested_attributes(association_name, *args)
end

@fields ||= {}
@fields[fields_blueprint_id_for(association_name)] = { :block => block, :options => options }
@fields[fields_blueprint_id_for(options[:blueprint] || association_name)] = { :block => block, :options => options }
super(association_name, *(args << block))
end

Expand Down