HotReload with Ruby On Rails 7

Grzegorz Smajdor
1 min readOct 17, 2022

--

At deliverists.io we build a custom software and deliver quality products to our clients. Some time ago, we worked on the project with clojurescript.

There are many benefits of this language, however, the focus today is on the feature called hot-reload. The idea is super simple, yet powerful, as the web page is being reloaded on file save. This small but useful feature saved me few keystrokes and allowed me to stayed focused in the editior while seeing immediate changes on the view opened in the browser.

As you can see above, without moving out from my editor, the page reloads and I can see the changes immediately! Now… lets replicate that behavior in Ruby on Rails 7.

Lets quickly build a new Ruby on Rails app

gem install rails
rails new test-app --css tailwind
cd test-app
./bin/dev

Then we need to do few configuration changes:

  1. Edit Gemfile and add hotwire-livereload gem
group :development do
gem "hotwire-livereload"
end

2. Install with bundler

bundle install

3. Run installation

rails livereload:install

4. Install Redis (osx brew)

brew install redis

5. Run Redis

brew services restart redis

6. Run Rails

./bin/dev

Edit the file and see the changes!

No more switching windows, hitting F5! Thats a live and time safer

Have fun and keep coding,

Grzegorz founder of deliverists.io

--

--