Is there some way to reload all gems in a Rails app without completely restarting the server? I've got a Gemfile that uses :path
to reference a dependency that I'm developing on the same system, and it's annoying to have to kill the app and do rails -s
again every time I save a change. It'd also be nice in production to be able to update a gem without killing the server for a few seconds. Thoughts?
Recently I found that I would like to do the same as you say, so I can develop gems along with my projects.
In a Gemfile I did not include gem dependency, but instead I added in config/environments/development.rb
ActiveSupport::Dependencies.autoload_paths << "/path_to_gem_dir/gem_name/lib"
It requires me to do some additional work with making it sync, but in most common cases it is ok. When I finish working on a gem I can remove autoload and use gem dependency in Gemfile.
Remember that gem dependency can be placed in :production, :test groups, so in development you have it cleaned.
For example
group :development do
# gem "wirble" COMMENTED!, so I can autoload files!
end
group :production do
gem "wirble"
end
Happy coding!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With