mirror of https://github.com/rails/rails
Ask if the instance variable is defined before asking for it, avoid *many* warnings.
This commit is contained in:
parent
9027721b11
commit
7c8b43ed4f
|
@ -991,7 +991,11 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
def object
|
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
|
rescue NameError
|
||||||
# As @object_name may contain the nested syntax (item[subobject]) we
|
# As @object_name may contain the nested syntax (item[subobject]) we
|
||||||
# need to fallback to nil.
|
# need to fallback to nil.
|
||||||
|
|
Loading…
Reference in New Issue