# How to call the same turbio\_stream template from different controller actions

**URL:** <https://discuss.hotwired.dev/t/how-to-call-the-same-turbio-stream-template-from-different-controller-actions/2697>\
**Category:** General\
**Created:** [April 15, 2021, 1:12am UTC](https://discuss.hotwired.dev/t/how-to-call-the-same-turbio-stream-template-from-different-controller-actions/2697 "2021-04-15T01:12:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dazza](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/dazza/32/1439_2.png) [@dazza](https://discuss.hotwired.dev/u/dazza)\
**Post date:** [April 15, 2021, 1:12am UTC](https://discuss.hotwired.dev/t/how-to-call-the-same-turbio-stream-template-from-different-controller-actions/2697/1 "2021-04-15T01:12:41Z")

</div>

I am really struggling to understand turbo\_streams. For some reason my turbo\_frames aren’t working in the way I was expecting as it seems to be replacing the whole page (according to Chrome Developer screens). I thought it replaced only the section on the page within the frame.

The problem I now seem to have … I have three controller methods which either delete, add or completely replace a list of time codes for a video I’m processing.

Each turbo\_stream.erb file calls exactly the same code as shown:

```
<%= turbo_stream.replace "updatetimecode" do %>
  <%= turbo_frame_tag "updatetimecode" do %>
    <%= render partial: 'showtimecodes' %>
  <% end %>
<% end %>

```

It seems really silly that I have three files with exactly the same thing:

`addtimecode.turbo_stream.erb`, `add_timecodes.turbo_stream.erb` and `delete_timecodes.turbo_stream.erb` which all correspond with controller actions.

One of which is below which I use following some advice on how to get turbo\_stream to replace just the section of the page which turbo\_frames seems to not be doing.

```
  def changetime
    # Designed to load the video at the time code
    time = params[:time]
    @newtime = time.split(':').map(&:to_i).inject(0) { |a, b| a * 60 + b }
    respond_to do |format|
      format.turbo_stream {}
    end
  end

```

How do I get each controller to replace the section of the page, but by calling only one turbo\_stream template?

Thanks in advance for any help you can give.

PS. Is there anyone who has done a kick butt tutorial on how to make this work (from a relatively new person perspective)? I find the examples on the page hard to follow from a Rails point of view.

---

<div class="post-metadata">

**Author:** ![tleish](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/tleish/32/920_2.png) [@tleish](https://discuss.hotwired.dev/u/tleish)\
**Post date:** [April 15, 2021, 3:39am UTC](https://discuss.hotwired.dev/t/how-to-call-the-same-turbio-stream-template-from-different-controller-actions/2697/2 "2021-04-15T03:39:11Z")

</div>

The approach I might take is redirect all other actions to a single new action (on the same controller or a new controller) which returns the turbo\_stream. The redirect should carry the turbo\_stream to the next action, so your logic should work.

I’ve done this before, but not with params. You may need to include the params in the redirect in order to get it to work properly.
