hotwired / turbo-rails

Use Turbo in your Ruby on Rails app
https://turbo.hotwired.dev
MIT License
2.07k stars 318 forks source link

locals: {action: nil} now results in undefined local variable or method. #570

Open rubys opened 6 months ago

rubys commented 6 months ago

Upgrading a rails 7.1 project that uses broadcast_replace_to to turbo-rails 2/turbo 8, resulted in the following test failure:

ActionView::Template::Error: undefined local variable or method `action' for an instance of #<Class:0x000000011ef58ad8>
    app/views/scores/_last_update.html.erb:1

In my case, setting locals: {action: false} will achieve the desired result, so I have a workaround, but previously I could set a local variable to nil. I've yet to find any docs that indicate that this is an intentional change in behavior.

If it helps, doing a git bisect identified the following as the change that broke this:

And links to the code that this change broke:

While turbo 8 provides other means by which this could be implemented, my impression was that this should continue to work.

jjongs08 commented 6 months ago

I am using broadcast_append_later_to, but I am experiencing the same issue.

It seems that the problem is caused by a change in the logic of the broadcast_rendering_with_defaults method.

Can someone explain why compact is used in this code?

shanereddy commented 2 months ago

I am experiencing the same issue after upgrading to 2.0.5.