Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reset template variables after using render_to_string. Closes #2559

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2723 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 86a571090c43cd00284e563b63a79016acc2f18b 1 parent 3a2943c
@seckar seckar authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Reset template variables after using render_to_string [skaes@web.de]
+
* Expose the session model backing CGI::Session
* Abbreviate RAILS_ROOT in traces
View
2  actionpack/lib/action_controller/base.rb
@@ -623,6 +623,8 @@ def render(options = nil, deprecated_status = nil) #:doc:
def render_to_string(options = nil) #:doc:
result = render(options)
erase_render_results
+ @variables_added = nil
+ @template.instance_variable_set("@assigns_added", nil)
result
end
View
9 actionpack/test/controller/render_test.rb
@@ -89,6 +89,10 @@ def accessing_local_assigns_in_inline_template_with_string_keys
ActionView::Base.local_assigns_support_string_keys = false
end
+ def render_to_string_test
+ @foo = render_to_string :inline => "this is a test"
+ end
+
def rescue_action(e) raise end
private
@@ -209,6 +213,11 @@ def test_render_to_string
assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", process_request.body
end
+ def test_render_to_string_resets_assigns
+ @request.action = "render_to_string_test"
+ assert_equal "The value of foo is: ::this is a test::\n", process_request.body
+ end
+
def test_nested_rendering
@request.action = "hello_world"
assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body
View
1  actionpack/test/fixtures/test/render_to_string_test.rhtml
@@ -0,0 +1 @@
+The value of foo is: ::<%= @foo %>::
Please sign in to comment.
Something went wrong with that request. Please try again.