Skip to content

Instantly share code, notes, and snippets.

@spalenza
Created January 5, 2016 02:31
Show Gist options
  • Save spalenza/0ac4ac85f95df2f43c06 to your computer and use it in GitHub Desktop.
Save spalenza/0ac4ac85f95df2f43c06 to your computer and use it in GitHub Desktop.
Namespace stuff in your app/ folder
# config/initializers/forms.rb
Rails.application.config.to_prepare do
path = Rails.root + "app/forms"
ActiveSupport::Dependencies.autoload_paths -= [path.to_s]
reloader = ActiveSupport::FileUpdateChecker.new [], path.to_s => [:rb] do
ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear
Dir[path + "**/*.rb"].each do |file|
ActiveSupport.require_or_load file
end
end
Rails.application.reloaders << reloader
ActionDispatch::Reloader.to_prepare { reloader.execute_if_updated }
reloader.execute
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment