diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-07-18 15:42:22 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-07-18 15:42:22 +0000 |
commit | 101ebc996a241fab4adcbbaf6c8930dddde8d091 (patch) | |
tree | 951417ed2e287536b60e6fa37206c4da7964843c /actionpack/lib/action_view | |
parent | 9ac7afcf63efa70a5bf31b642654715eaffe8b90 (diff) | |
download | rails-101ebc996a241fab4adcbbaf6c8930dddde8d091.tar.gz rails-101ebc996a241fab4adcbbaf6c8930dddde8d091.tar.bz2 rails-101ebc996a241fab4adcbbaf6c8930dddde8d091.zip |
Allow form_for and fields_for to work with indexed form inputs. [Jeremy Kemper, Matt Lyon]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4613 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index eef7d1f567..43185e3a0c 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -238,7 +238,11 @@ module ActionView @template_object, @local_binding = template_object, local_binding @object = object if @object_name.sub!(/\[\]$/,"") - @auto_index = @template_object.instance_variable_get("@#{Regexp.last_match.pre_match}").id_before_type_cast + if object ||= @template_object.instance_variable_get("@#{Regexp.last_match.pre_match}") and object.respond_to?(:id_before_type_cast) + @auto_index = object.id_before_type_cast + else + raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to id_before_type_cast: #{object.inspect}" + end end end |