Why does Turbo Stream update care about the entire page?

Hi there,
I have the following situation, an aside with some links, a table and a button that relies on the @plan variable to be rendered or not.

When clicking one of the link, an action is triggered with turbo stream format.

def index
  @items = Item.where(phase_id: params[:phase_id])
end

The view looks like (items is the ID of the tbody element within the table on the right).

<%= turbo_stream.update "items" do %>
  <%= render partial: "masterdata/item", collection: @items, as: :item %>
<% end %>

When I click on the aside links I get an error because the @plan variable is not defined and Rails doesn’t know how if it has to render the button. The code responsible to render the button looks like

<% if @plan.active? %>
  <%= tag.button ... %>
<% end %>

Shouldn’t the turbo stream action only replace the content within #items without caring about the rest of the page?

Thanks,

Are you sure the turbo_stream template is actually being rendered? Posting a full call stack of the error might help, but I am pretty sure the request is not being handled as turbo_stream.

Hi @honzasterba,
My bad; after reviewing the flow again, I noticed a reference to @control_plan inside the master data/item partial that I overlooked before. Therefore, everything works as expected.

Thanks for your help.