Rails Live Reload
This is the simplest and probably the most robust way to add live reloading to your Rails app.
Just add the gem and thats it, now you have a live reloading. You don't need anything other than this gem for live reloading to work.
- views (EBR/HAML/SLIM) (the page is reloaded only when changed views which were rendered on the page)
- helpers (if configured)
- YAML locales (if configured)
- on the "crash" page, so it will be reloaded as soon as you make a fix
The page is reloaded fully with
window.location.reload() to make sure that every chage will be displayed.
Just add this gem to the Gemfile (in development environment) and start the
Add this line to your application's Gemfile:
group :development do gem "rails_live_reload" end
And then execute:
How it works
There are 3 main parts:
- listener of file changes (using
- collector of rendered views (see rails instrumentation)
The default configuration assumes that you either use asset pipeline, or that your assets compile quickly (on most applications asset compilation takes around 50-200ms), so it watches for changes in
You are welcome to contribute. See list of
- reload CSS without reloading the whole page?
- smarter reload if there is a change in helper (check methods from rendered views?)
- generator for initializer
- more complex rules? e.g. if "user.rb" file is changed - reload all pages with rendered "users" views
- check with older Rails versions
- tests or specs
- CI (github actions)
- auto reload when rendered controller was changed
Too many open files - pipe- increase limits by
ulimit -n 10000
The gem is available as open source under the terms of the MIT License.