diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-28 10:37:46 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-28 10:37:46 -0500 |
commit | acbf2b74aa3001fb6064bba96cd0033495774357 (patch) | |
tree | 54bd7e783a063ddf359721eefd2a5566d12a9a0f /actionpack | |
parent | 8b6870cfae8d50a2ffd4f024d33d51aadaa6a6f7 (diff) | |
download | rails-acbf2b74aa3001fb6064bba96cd0033495774357.tar.gz rails-acbf2b74aa3001fb6064bba96cd0033495774357.tar.bz2 rails-acbf2b74aa3001fb6064bba96cd0033495774357.zip |
Deprecated implicit local assignments when rendering partials
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderable_partial.rb | 10 | ||||
-rw-r--r-- | actionpack/test/controller/new_render_test.rb | 6 |
3 files changed, 14 insertions, 4 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index f6942b43f1..6717162d1e 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Deprecated implicit local assignments when rendering partials [Josh Peek] + * Introduce current_cycle helper method to return the current value without bumping the cycle. #417 [Ken Collins] * Allow polymorphic_url helper to take url options. #880 [Tarmo Tänav] diff --git a/actionpack/lib/action_view/renderable_partial.rb b/actionpack/lib/action_view/renderable_partial.rb index 5203e57ead..123a9aebbc 100644 --- a/actionpack/lib/action_view/renderable_partial.rb +++ b/actionpack/lib/action_view/renderable_partial.rb @@ -27,8 +27,14 @@ module ActionView def render_partial(view, object = nil, local_assigns = {}, as = nil) object ||= local_assigns[:object] || - local_assigns[variable_name] || - view.controller.instance_variable_get("@#{variable_name}") if view.respond_to?(:controller) + local_assigns[variable_name] + + if view.respond_to?(:controller) + object ||= ActiveSupport::Deprecation::DeprecatedObjectProxy.new( + view.controller.instance_variable_get("@#{variable_name}"), + "@#{variable_name} will no longer be implicitly assigned to #{variable_name}" + ) + end # Ensure correct object is reassigned to other accessors local_assigns[:object] = local_assigns[variable_name] = object diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 82919b7777..698c46f78c 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -832,8 +832,10 @@ EOS end def test_partial_with_implicit_local_assignment - get :partial_with_implicit_local_assignment - assert_equal "Hello: Marcel", @response.body + assert_deprecated do + get :partial_with_implicit_local_assignment + assert_equal "Hello: Marcel", @response.body + end end def test_render_missing_partial_template |