class Project < ApplicationRecord
broadcasts_to ->(project) { project}, partial: 'projects/project' // have to explicitly set partial to handle child classes
...
end
and one of the child classes is
class Project::Holiday < Project
...
end
For this issue, the first line of the partial is <div id="<%= dom_id(project) -%>">. This is where our error is happening.
When we create a new Project, everything works fine. When we create a new Project::Holiday, the broadcast job errors with the following error:
Failure/Error: <div id="<%= dom_id(project_holiday) -%>">
ActionView::Template::Error:
undefined local variable or method `project_holiday' for an instance of #<Class:0x000000013e0db058>
How would we handle this to work with STI?
Things we have tried:
Passing in a locals object to the partial. This did not work.
Passing in an object param to broadcasts_to. This did not work.
Adding the broadcasts_to line to project/holiday.rb but this just seemed to be ignored. We confirmed that by removing the partial param on the base class and this errored with Missing partial project/holidays/_holiday with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}.
We have a model using STI.
Our base model looks like this:
and one of the child classes is
For this issue, the first line of the partial is
<div id="<%= dom_id(project) -%>">
. This is where our error is happening.When we create a new
Project
, everything works fine. When we create a newProject::Holiday
, the broadcast job errors with the following error:How would we handle this to work with STI?
Things we have tried:
locals
object to the partial. This did not work.object
param to broadcasts_to. This did not work.broadcasts_to
line toproject/holiday.rb
but this just seemed to be ignored. We confirmed that by removing thepartial
param on the base class and this errored withMissing partial project/holidays/_holiday with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}.
Any ideas?