Skip to content

Commit a31f764

Browse files
authored
Merge pull request rails#42169 from etiennebarrie/restore-implicit-to_s-for-content_for
Restore implicit `to_s` for `content_for` and `provide`
2 parents 226f22e + f55f923 commit a31f764

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

actionview/lib/action_view/flows.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def get(key)
1717

1818
# Called by each renderer object to set the layout contents.
1919
def set(key, value)
20-
@content[key] = ActiveSupport::SafeBuffer.new(value)
20+
@content[key] = ActiveSupport::SafeBuffer.new(value.to_s)
2121
end
2222

2323
# Called by content_for
2424
def append(key, value)
25-
@content[key] << value
25+
@content[key] << value.to_s
2626
end
2727
alias_method :append!, :append
2828
end

actionview/test/template/capture_helper_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def test_content_for_used_for_read
5151
def test_content_for_with_multiple_calls
5252
assert_not content_for?(:title)
5353
content_for :title, "foo"
54-
content_for :title, "bar"
54+
content_for :title, :bar
5555
assert_equal "foobar", content_for(:title)
5656
end
5757

5858
def test_content_for_with_multiple_calls_and_flush
5959
assert_not content_for?(:title)
6060
content_for :title, "foo"
61-
content_for :title, "bar", flush: true
61+
content_for :title, :bar, flush: true
6262
assert_equal "bar", content_for(:title)
6363
end
6464

@@ -172,7 +172,7 @@ def test_provide
172172
assert_equal "hi&lt;p&gt;title&lt;/p&gt;", content_for(:title)
173173

174174
@view_flow = ActionView::OutputFlow.new
175-
provide :title, "hi"
175+
provide :title, :hi
176176
provide :title, raw("<p>title</p>")
177177
assert_equal "hi<p>title</p>", content_for(:title)
178178
end

0 commit comments

Comments
 (0)