Link to the : YOUTUBE CHANNEL
Link to the video : https://youtu.be/3H-vcOdFKYc
-
In the video i explain how to add Auto Reload for Rails Applications. It can be done with some few steps.
-
Below you can read all the steps in text form. For the video you can visit this LINK
-
Check this list at the end of this Readme to see the different locations that we needed to add new codes
For this we need to add guard-livereload and rack-livereload gem to our Gemfile. We need to add the gem to Development Group , because we need it only in Development
group :development do
gem 'guard-livereload', '~> 2.5', require: false
gem 'rack-livereload'
end
Then in the terminal write :
$ bundle install
This command will download and configure all needed Configs
- Now in the Terminal write :
This command will add Guardfile to the project.
$ bundle exec guard init livereload
- Now we need add a line to our Rails middleware stack
For this open config/environments/development.rb
Add the code below to the end of the file
# Add Rack::LiveReload to the bottom of the middleware stack with the default options: config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload
We are all set now all we need is running the rails Server again with :
$ rails s
and in a new tab of the terminal run :
$ bundle exec guard
Now enjoy Developing while your browser refreshes after any change
If you had any Issues that the changes in scss files are not watched. In Guardfile add this line :
# file needing a full reload of the page anyway
watch(%r{app/assets/stylesheets/.+\.scss})
Make Sure to restart livereload and rails servers , otherwise the changes will not take effect
- Gems we added in Gemfile
- Line we added in Middelware
- Line we added in Guardfile