Skip to content

Instantly share code, notes, and snippets.

@paneq
Created April 15, 2011 11:03
Show Gist options
  • Save paneq/921526 to your computer and use it in GitHub Desktop.
Save paneq/921526 to your computer and use it in GitHub Desktop.
Changed piece of railties-3.0.7.rc1/lib/rails/application/bootstrap.rb Clear dependencies before request only when some changes were made to any file observed by watchr.
initializer :set_clear_dependencies_hook do
unless config.cache_classes
changed_at = Proc.new{ File.new(File.join(Rails.root, '.watchr')).mtime }
last_change = changed_at.call
ActionDispatch::Callbacks.before do
change = changed_at.call
if change > last_change
Rails.logger.info("DETECTED CHANGES")
last_change = change
ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment