diff options
author | Sergey Novikov <novikov359@gmail.com> | 2017-09-18 22:12:51 +0200 |
---|---|---|
committer | Sergey Novikov <novikov359@gmail.com> | 2017-09-18 22:12:51 +0200 |
commit | 3b9e3ceff5a7a3a55aec400f1956f56fdbdd5efc (patch) | |
tree | a137e59ea72d80b1c9be217505917dfc295a82d3 | |
parent | e4017d0288fff13be9e97335c37ebbd30d1e94ea (diff) | |
download | rails-3b9e3ceff5a7a3a55aec400f1956f56fdbdd5efc.tar.gz rails-3b9e3ceff5a7a3a55aec400f1956f56fdbdd5efc.tar.bz2 rails-3b9e3ceff5a7a3a55aec400f1956f56fdbdd5efc.zip |
Allow usage of strings as locals for partial renderer
-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 beb0a18b65..8534eeb518 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 9df2a73448..6e61b12285 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -489,6 +489,10 @@ class TestController < ApplicationController 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 @@ -1169,6 +1173,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 |