diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-09-28 15:53:32 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-09-28 15:53:32 -0300 |
commit | 7c8b43ed4fba035033e28cc47358fc3908584880 (patch) | |
tree | b6ce5f7f2b8e2f04015f6610f1825c54b2cd007f /actionpack/lib/action_view | |
parent | 9027721b11436144e65bceb9e29ad8669b02582a (diff) | |
download | rails-7c8b43ed4fba035033e28cc47358fc3908584880.tar.gz rails-7c8b43ed4fba035033e28cc47358fc3908584880.tar.bz2 rails-7c8b43ed4fba035033e28cc47358fc3908584880.zip |
Ask if the instance variable is defined before asking for it, avoid *many* warnings.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 6 |
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. |