1,360 Experience
13 Lessons Completed
0 Questions Solved


Posted in Turbo stream problem

Thank you for your reply...

I was under the impression that


would be enough. But that doesn't include create I guess.

ActionCable seems like a hassle to set up. Thought turbo could do this.
I'll just add some javascript 🫣 to handle some kind of fetch new function

Posted in Turbo stream problem


I'm having a problem with a view not fully auto-updating using turbo.
It currently only works when updating or destroying.

So to keep it kinda short, I have a site where users can crud some products. On an office screen, products are listed. All updates shows up automatically. Newly created products can only be loaded if this view is refreshed.

The product.rb simply uses


The route has

resources :products
get "screen", to: "products#screen"

The new and edit templates doesn't use turbo. And the product_controller simply does something like:

def create
        @product =
            redirect_to products_path
            render :new

In the products_controller I also define the 'screen'

def screen
        @products = Product.all

And on the views/products/screen.html.erb I do

<% @products.each do |product| %>
  <%= turbo_stream_from product %>
  <%= render partial: "product", locals: { product: product } %>
<% end %>

and the views/products/_product.html.erb

<div id="<%= dom_id product%>">
  <%= product_name %>

What am I missing?
Thank you

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.