Ask if the instance variable is defined before asking for it, avoid *many* warnings.

This commit is contained in:
Emilio Tagua 2010-09-28 15:53:32 -03:00
parent 9027721b11
commit 7c8b43ed4f
1 changed files with 5 additions and 1 deletions

View File

@ -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.