Skip to content

Instantly share code, notes, and snippets.

@jumski
Created July 11, 2012 14:28
Show Gist options
  • Save jumski/3090722 to your computer and use it in GitHub Desktop.
Save jumski/3090722 to your computer and use it in GitHub Desktop.
Rails 3: reload custom files at each request (or in console using reload!)
if Rails.env.development?
decorator_paths = Dir['app/**/*_decorator.rb']
decorators_reloader = ActiveSupport::FileUpdateChecker.new(decorator_paths) do
decorator_paths.each { |path| load path }
end
ActionDispatch::Callbacks.to_prepare do
decorators_reloader.execute_if_updated
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment