DEV Community

Discussion on: How to set-up Rails Hotwire live reload

Collapse
 
chidoyo profile image
Erick Adrian Perez

I love this new LiveReload and I have been using it on a Rails 7 app I've been using for practice on tutorials, etc.
I love it so much that I decided to try to install it to a small Rails app at work that we use to show design prototypes.
So I decided to install it to this existing app that was running on rails '5.2.4'.
I just updated it to rails '7.0.2'
Update was simple and it was successful.
I followed the steps on this artible to install hotwire-livereload.
I got my first error when I tried to make a small change to a html.erb template. The error is:

Uncaught ReferenceError: Turbo is not defined

Does this mean that this livereload requires gem "turbo-rails" as a dependency?

I've tried installing it to my app but I'm running into the problem of this app not allowing me to add this line to my application.js file:

import '@hotwired/turbo-rails'

This app is a couple of years old so I don't use import on my JS files.
I also tried to add it like this but the file could not be found.

//= require @hotwired/turbo-rails

I think it's obvious that it requires turbo-rails since it's finding that Turbo is not defined.
What should I do to make this LiveReload work on a rails app that I've updated to rails 7?