aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.