From 7c8b43ed4fba035033e28cc47358fc3908584880 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:53:32 -0300 Subject: Ask if the instance variable is defined before asking for it, avoid *many* warnings. --- actionpack/lib/action_view/helpers/form_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack') 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. -- cgit v1.2.3