I am working to integrate turbo streams into a deeply nested resource.
Records are modeled so PortCall has many Shifts which has many Gangs which has many Counts.
During create, turbo stream appends the count no problem but scopes it to the wrong count (always the first id=‘counts’). How do I scope turbo stream to the correct parent element?
count.rb
class Count < ApplicationRecord
belongs_to :account
belongs_to :gang
belongs_to :operator
validates :duration, :moves_completed, :detention, presence: true
validates :duration, :moves_completed, :detention, numericality: true
after_create_commit -> { broadcast_append_to gang.shift.port_call }
after_destroy_commit -> { broadcast_remove_to gang.shift.port_call }
after_update_commit -> { broadcast_replace_to gang.shift.port_call }
end
