Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure render :collection doesnt set nil local when :as is absent

  • Loading branch information...
commit 267d3964ebd7bbc8879d69ff5a323527179c497d 1 parent 2b43620
@lifo lifo authored
View
3  actionpack/lib/action_view/partial_template.rb
@@ -23,7 +23,8 @@ def render
end
def render_member(object)
- @locals[:object] = @locals[@variable_name] = @locals[as] = object
+ @locals[:object] = @locals[@variable_name] = object
+ @locals[as] = object if as
template = render_template
@locals[@counter_name] += 1
View
1  actionpack/test/fixtures/test/_local_inspector.html.erb
@@ -0,0 +1 @@
+<%= local_assigns.keys.map(&:to_s).sort.join(",") -%>
View
5 actionpack/test/template/render_test.rb
@@ -59,6 +59,11 @@ def test_render_partial_collection_as
assert_equal "david david davidmary mary mary",
@view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer)
end
+
+ def test_render_partial_collection_without_as
+ assert_equal "local_inspector,local_inspector_counter,object",
+ @view.render(:partial => "test/local_inspector", :collection => [ Customer.new("mary") ])
+ end
# TODO: The reason for this test is unclear, improve documentation
def test_render_partial_and_fallback_to_layout
Please sign in to comment.
Something went wrong with that request. Please try again.