Ask A Question


You’re not receiving notifications from this thread.

Custom Turbo Stream Actions Discussion

Great episode! Is there any convention or recommendation for managing the JS code instead of throwing it all in the application.js? Something like app/javascript/stream_actions/console_log.js, etc, and then having an import statement that loads the entire folder?


You sure can do that. I would have each file register the function itself and all you'd need to is require those files.


I see you're importing from @hotwired/turbo

I have Rails 7 set up with importmaps so have the pin pin '@hotwired/turbo-rails', to: 'turbo.min.js' however trying import { StreamActions } from '@hotwired/turbo-rails' just results in the error: Uncaught SyntaxError: The requested module '@hotwired/turbo-rails' does not provide an export named 'StreamActions'

I've seen multiple different ways of solving the problem and even using something like turbo-power but what would be the recommended way of setting up the pins/imports/etc for a simple example like the console_log custom action?


Hi Chris, do you have plans to make a video on using turbo in rails 7 like we use ajax in older rails versions with rails UJS ?

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 74,071+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

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

    © 2023 GoRails, LLC. All rights reserved.