aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorJarl Friis <jarl@hermes.(none)>2009-05-11 14:09:22 +0200
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-02 11:55:24 -0700
commite61afed6f8d2ef6a580ba00a5beaaaf0bf2ddb9a (patch)
tree052da1cded5717c94b608f4903a3b1f5a6b725d7 /actionpack/lib/action_view/helpers/form_helper.rb
parent49bdbebca69cabea6e4cea6e09cb61dc990bb1f7 (diff)
downloadrails-e61afed6f8d2ef6a580ba00a5beaaaf0bf2ddb9a.tar.gz
rails-e61afed6f8d2ef6a580ba00a5beaaaf0bf2ddb9a.tar.bz2
rails-e61afed6f8d2ef6a580ba00a5beaaaf0bf2ddb9a.zip
My suggestion to fix ticket 2401 [#2401 state:resolved]
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb10
1 files changed, 6 insertions, 4 deletions
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