I'm upgrading an app from rails 5.2 to 6.1.7, as well as upgrading ruby from 2.6.10 to 3.0.5. Now all of the <%= render "partial_name" %>
blocks in the erb
view files are broken and throwing the error undefined method safe_append= for {:add_to_stack=>true}:Hash
with the hint: safe_append= is being called on a add_to_stack object, which might not be the type of object you were expecting.
This appears to be a deprecated ActionView::StreamingBuffer
method. I did ensure that actionview has also been updated to 6.1.7, and I'm also not seeing any streaming buffer breaking changes in Rails 6 or 6.1. I don't see any related issues online anywhere. Anyone know what could be causing this?

- 165
- 1
- 14
-
This seems to be a problem with the ruby version. When I drop to 2.7.6, the error goes away for some reason. – Ando Dec 30 '22 at 23:12
3 Answers
To officially answer my own question, this seems to have been too large of an upgrade to undertake. I broke this task up into smaller pieces and first upgraded to ruby 2.7.7
and rails 6.0.6.1
and was able to get things going.

- 165
- 1
- 14
Upgrade to ruby version 3.x is ok.
I faced with same issue. Please check my case at: https://stackoverflow.com/a/75995680/3510489

- 543
- 3
- 11
I am also seeing this error when I use Ruby 3.0 on an app that was upgraded from Rails 6.0 to 6.1.
In Rails, ActionView::Template#render has this signature:]
def render(view, locals, buffer = ActionView::OutputBuffer.new, add_to_stack: true, &block)
and it is being called by a line in ActionView::PartialRenderer
like this:
content = template.render(view, locals, add_to_stack: !block) do |*name|
view._layout_for(*name, &block)
end
and I think what is happening is that the keyword variable add_to_stack: !block
is being treated as a Hash and given to the positional variable buffer which isn't using the default for some reason. This makes sense with the change in Ruby version because the treatment of these keyword/positional variables are changing. But I don't understand what I need to do to fix it.
If I revert to Ruby 2.7.8 it works fine, and I thought Rails 6.1 was supposed to support Ruby 3.0.
-
Finally figured out what was happening: I was using an older version of the rack-mini-profiler gem, which had incompatibilities with Ruby 3.0.0. More info here: https://github.com/MiniProfiler/rack-mini-profiler/issues/480 Updating to >= 2.3.1 fixed it. – Matt Van Horn Apr 27 '23 at 17:47