Permalink
Browse files

Dup local assigns for partial collections so nil values doesn't get o…

…verwritten [#1250 state:resolved]
  • Loading branch information...
1 parent ef53d91 commit ec38c84ce1ff7f0888becc15e3f58337ca807e25 @josh josh committed Oct 30, 2008
@@ -181,7 +181,7 @@ def render_partial_collection(options = {}) #:nodoc:
ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path)
template = _pick_partial_template(_partial_path)
local_assigns[template.counter_name] = index
- result = template.render_partial(self, object, local_assigns, as)
+ result = template.render_partial(self, object, local_assigns.dup, as)
index += 1
result
end.join(spacer)
@@ -1 +1 @@
-Hello: <%= customer.name %>
+Hello: <%= customer.name rescue "Anonymous" %>
@@ -115,6 +115,10 @@ def test_render_partial_with_nil_collection_should_return_nil
assert_nil @view.render(:partial => "test/customer", :collection => nil)
end
+ def test_render_partial_with_nil_values_in_collection
+ assert_equal "Hello: davidHello: Anonymous", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), nil ])
+ end
+
def test_render_partial_with_empty_array_should_return_nil
assert_nil @view.render(:partial => [])
end

0 comments on commit ec38c84

Please sign in to comment.