aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-28 15:53:32 -0300
committerEmilio Tagua <miloops@gmail.com>2010-09-28 15:53:32 -0300
commit7c8b43ed4fba035033e28cc47358fc3908584880 (patch)
treeb6ce5f7f2b8e2f04015f6610f1825c54b2cd007f /actionpack/lib/action_view/helpers/form_helper.rb
parent9027721b11436144e65bceb9e29ad8669b02582a (diff)
downloadrails-7c8b43ed4fba035033e28cc47358fc3908584880.tar.gz
rails-7c8b43ed4fba035033e28cc47358fc3908584880.tar.bz2
rails-7c8b43ed4fba035033e28cc47358fc3908584880.zip
Ask if the instance variable is defined before asking for it, avoid *many* warnings.
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb6
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 8bae6d2796..7e49052c24 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -991,7 +991,11 @@ module ActionView
end
def object
- @object || @template_object.instance_variable_get("@#{@object_name}")
+ if @object
+ @object
+ elsif @template_object.instance_variable_defined?("@#{@object_name}")
+ @template_object.instance_variable_get("@#{@object_name}")
+ end
rescue NameError
# As @object_name may contain the nested syntax (item[subobject]) we
# need to fallback to nil.