Permalink
Browse files

Ask if the instance variable is defined before asking for it, avoid *…

…many* warnings.
  • Loading branch information...
1 parent 9027721 commit 7c8b43ed4fba035033e28cc47358fc3908584880 @miloops miloops committed Sep 28, 2010
Showing with 5 additions and 1 deletion.
  1. +5 −1 actionpack/lib/action_view/helpers/form_helper.rb
@@ -991,7 +991,11 @@ def to_content_tag(tag_name, options = {})
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.

0 comments on commit 7c8b43e

Please sign in to comment.