I've got a Rails app which uses a gem I'm actively developing. How can I instruct the app to reload the gem on every request?
This solution almost works but for some reason I have to put it into application.rb
and not in environments/development.rb
otherwise the autoload_paths are not recognized.
I added some additional stuff which fetches the paths automagically.
if Rails.env.development? reload_gems = %w(my_gem other_gem) # names of gems which should autoreload config.autoload_paths += Gem.loaded_specs.values.inject([]){ |a,gem| a += gem.load_paths if reload_gems.include? gem.name; a } require 'active_support/dependencies' ActiveSupport::Dependencies.explicitly_unloadable_constants += reload_gems.map { |gem| gem.classify } end
Local gems can be added with gem 'my_gem', :path => '../my_gem'
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