From e61afed6f8d2ef6a580ba00a5beaaaf0bf2ddb9a Mon Sep 17 00:00:00 2001 From: Jarl Friis Date: Mon, 11 May 2009 14:09:22 +0200 Subject: My suggestion to fix ticket 2401 [#2401 state:resolved] Signed-off-by: Yehuda Katz + Carl Lerche --- actionpack/lib/action_view/helpers/form_helper.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 8ecec87b10..6d6d623938 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -926,6 +926,7 @@ module ActionView attr_accessor :object_name, :object, :options def initialize(object_name, object, template, options, proc) + @nested_child_index = {} @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc @default_options = @options ? @options.slice(:index) : {} if @object_name.to_s.match(/\[\]$/) @@ -1028,7 +1029,7 @@ module ActionView explicit_child_index = args.last[:child_index] if args.last.is_a?(Hash) children.map do |child| - fields_for_nested_model("#{name}[#{explicit_child_index || nested_child_index}]", child, args, block) + fields_for_nested_model("#{name}[#{explicit_child_index || nested_child_index(name)}]", child, args, block) end.join else fields_for_nested_model(name, explicit_object || association, args, block) @@ -1046,9 +1047,9 @@ module ActionView end end - def nested_child_index - @nested_child_index ||= -1 - @nested_child_index += 1 + def nested_child_index(name) + @nested_child_index[name] ||= -1 + @nested_child_index[name] += 1 end end end @@ -1056,5 +1057,6 @@ module ActionView class << Base attr_accessor :default_form_builder end + Base.default_form_builder = ::ActionView::Helpers::FormBuilder end -- cgit v1.2.3