public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Deprecated implicit local assignments when rendering partials
josh (author)
Thu Aug 28 08:37:46 -0700 2008
commit  acbf2b74aa3001fb6064bba96cd0033495774357
tree    54bd7e783a063ddf359721eefd2a5566d12a9a0f
parent  8b6870cfae8d50a2ffd4f024d33d51aadaa6a6f7
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Deprecated implicit local assignments when rendering partials [Josh Peek]
0
+
0
 * Introduce current_cycle helper method to return the current value without bumping the cycle.  #417 [Ken Collins]
0
 
0
 * Allow polymorphic_url helper to take url options. #880 [Tarmo Tänav]
...
27
28
29
30
31
 
 
 
 
 
 
 
 
32
33
34
...
27
28
29
 
 
30
31
32
33
34
35
36
37
38
39
40
0
@@ -27,8 +27,14 @@ module ActionView
0
 
0
     def render_partial(view, object = nil, local_assigns = {}, as = nil)
0
       object ||= local_assigns[:object] ||
0
-        local_assigns[variable_name] ||
0
-        view.controller.instance_variable_get("@#{variable_name}") if view.respond_to?(:controller)
0
+        local_assigns[variable_name]
0
+
0
+      if view.respond_to?(:controller)
0
+        object ||= ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
0
+          view.controller.instance_variable_get("@#{variable_name}"),
0
+          "@#{variable_name} will no longer be implicitly assigned to #{variable_name}"
0
+        )
0
+      end
0
 
0
       # Ensure correct object is reassigned to other accessors
0
       local_assigns[:object] = local_assigns[variable_name] = object
...
832
833
834
835
836
 
 
 
 
837
838
839
...
832
833
834
 
 
835
836
837
838
839
840
841
0
@@ -832,8 +832,10 @@ EOS
0
   end
0
 
0
   def test_partial_with_implicit_local_assignment
0
-    get :partial_with_implicit_local_assignment
0
-    assert_equal "Hello: Marcel", @response.body
0
+    assert_deprecated do
0
+      get :partial_with_implicit_local_assignment
0
+      assert_equal "Hello: Marcel", @response.body
0
+    end
0
   end
0
 
0
   def test_render_missing_partial_template
...
162
163
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
166
167
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
0
@@ -162,6 +162,22 @@ module ActiveSupport
0
         end
0
     end
0
 
0
+    class DeprecatedObjectProxy < DeprecationProxy
0
+      def initialize(object, message)
0
+        @object = object
0
+        @message = message
0
+      end
0
+
0
+      private
0
+        def target
0
+          @object
0
+        end
0
+
0
+        def warn(callstack, called, args)
0
+          ActiveSupport::Deprecation.warn(@message, callstack)
0
+        end
0
+    end
0
+
0
     # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc.
0
     # which emits deprecation warnings on any method call (except +inspect+).
0
     class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc:

Comments