aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-03-01 10:04:05 +1030
committerMatthew Draper <matthew@trebex.net>2016-03-02 02:14:54 +1030
commit60b53e9883bfd9f4edb640dbe2de89227b875e09 (patch)
tree5a9b71599660d575942f6b03b01b977ad4b204f2 /actionpack/lib/action_dispatch
parent5bdeb9bfd72a97ad578efc6cce95283f589f1555 (diff)
downloadrails-60b53e9883bfd9f4edb640dbe2de89227b875e09.tar.gz
rails-60b53e9883bfd9f4edb640dbe2de89227b875e09.tar.bz2
rails-60b53e9883bfd9f4edb640dbe2de89227b875e09.zip
Don't reference Rails.application from inside a component
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/middleware/reloader.rb16
-rw-r--r--actionpack/lib/action_dispatch/railtie.rb2
2 files changed, 8 insertions, 10 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/reloader.rb b/actionpack/lib/action_dispatch/middleware/reloader.rb
index e5cc588bd6..112bde6596 100644
--- a/actionpack/lib/action_dispatch/middleware/reloader.rb
+++ b/actionpack/lib/action_dispatch/middleware/reloader.rb
@@ -33,26 +33,22 @@ module ActionDispatch
end
def self.prepare!
- if defined? Rails.application.reloader
- Rails.application.reloader.prepare!
- else
- ActiveSupport::Reloader.prepare!
- end
+ default_reloader.prepare!
end
def self.cleanup!
- if defined? Rails.application.reloader
- Rails.application.reloader.reload!
- else
- ActiveSupport::Reloader.reload!
- end
+ default_reloader.reload!
end
class << self
+ attr_accessor :default_reloader # :nodoc:
+
deprecate to_prepare: 'use ActiveSupport::Reloader.to_prepare instead',
to_cleanup: 'use ActiveSupport::Reloader.to_complete instead',
prepare!: 'use Rails.application.reloader.prepare! instead',
cleanup!: 'use Rails.application.reloader.reload! instead of cleanup + prepare'
end
+
+ self.default_reloader = ActiveSupport::Reloader
end
end
diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb
index ddeea24bb3..e9e6a2e597 100644
--- a/actionpack/lib/action_dispatch/railtie.rb
+++ b/actionpack/lib/action_dispatch/railtie.rb
@@ -39,6 +39,8 @@ module ActionDispatch
config.action_dispatch.always_write_cookie = Rails.env.development? if config.action_dispatch.always_write_cookie.nil?
ActionDispatch::Cookies::CookieJar.always_write_cookie = config.action_dispatch.always_write_cookie
+ ActionDispatch::Reloader.default_reloader = app.reloader
+
ActionDispatch.test_app = app
end
end