How to reload a gem on every request in Development mode? [closed]

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'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)