Skip to content

Commit 4568cbe

Browse files
committed
Use the Rails 5 reloader API if available
Maintains compat with older Rails as well, but uses the new reloader API if it's available, avoiding a deprecation warning on Rails 5.0 and breakage on Rails 5.1.
1 parent f90890b commit 4568cbe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/spring/application.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,13 @@ def serve(client)
149149
setup command
150150

151151
if Rails.application.reloaders.any?(&:updated?)
152-
ActionDispatch::Reloader.cleanup!
153-
ActionDispatch::Reloader.prepare!
152+
# Rails 5.1 forward-compat. AD::R is deprecated to AS::R in Rails 5.
153+
if defined? ActiveSupport::Reloader
154+
Rails.application.reloader.reload!
155+
else
156+
ActionDispatch::Reloader.cleanup!
157+
ActionDispatch::Reloader.prepare!
158+
end
154159
end
155160

156161
pid = fork {

0 commit comments

Comments
 (0)