Skip to content

Instantly share code, notes, and snippets.

@artero
Forked from oriolbcn/reload.rb
Created July 25, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artero/d55459b8aaf94d8454fdde7099713f9b to your computer and use it in GitHub Desktop.
Save artero/d55459b8aaf94d8454fdde7099713f9b to your computer and use it in GitHub Desktop.
Reload gem from library in Rails 5+
if Rails.env.development?
localistico_files = Dir['lib/localistico/*.rb'] + ['lib/localistico.rb']
reloader = ActiveSupport::FileUpdateChecker.new(localistico_files) do
localistico_files.each { |file| load file }
end
ActiveSupport::Reloader.to_prepare do
reloader.execute_if_updated
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment