diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-04-27 19:17:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 19:17:36 -0400 |
commit | ce58a64f19cf1b7d538f0e1d75fe1ddc7e68bf2e (patch) | |
tree | ccaeb88adacf0898f0a9d7453d23c281ae6b5a79 /actionview | |
parent | a189adf4e5d58dcb05012b3b569d1de2fa496974 (diff) | |
parent | 3b9e3ceff5a7a3a55aec400f1956f56fdbdd5efc (diff) | |
download | rails-ce58a64f19cf1b7d538f0e1d75fe1ddc7e68bf2e.tar.gz rails-ce58a64f19cf1b7d538f0e1d75fe1ddc7e68bf2e.tar.bz2 rails-ce58a64f19cf1b7d538f0e1d75fe1ddc7e68bf2e.zip |
Merge pull request #30647 from droptheplot/render-partials-string-locals
Allow usage of strings as locals for partial renderer
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer.rb | 2 | ||||
-rw-r--r-- | actionview/test/actionpack/controller/render_test.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index 5b40af4f2f..d7f97c3b50 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -363,7 +363,7 @@ module ActionView @options = options @block = block - @locals = options[:locals] || {} + @locals = options[:locals] ? options[:locals].symbolize_keys : {} @details = extract_details(options) prepend_formats(options[:formats]) diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb index e059f37d38..3e6b55a87e 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -485,6 +485,10 @@ class TestController < ActionController::Base render partial: "customer", locals: { customer: Customer.new("david") } end + def partial_with_string_locals + render partial: "customer", locals: { "customer" => Customer.new("david") } + end + def partial_with_form_builder render partial: ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {}) end @@ -1170,6 +1174,11 @@ class RenderTest < ActionController::TestCase assert_equal "Hello: david", @response.body end + def test_partial_with_string_locals + get :partial_with_string_locals + assert_equal "Hello: david", @response.body + end + def test_partial_with_form_builder get :partial_with_form_builder assert_equal "<label for=\"post_title\">Title</label>\n", @response.body |