Skip to content

Commit b6dc87e

Browse files
committed
Recommend setting enable_reloading on newer Rails versions
1 parent 2380451 commit b6dc87e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/spring/application.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,14 @@ def preload
102102

103103
Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
104104
if Rails.application.config.cache_classes
105+
config_name, set_to = if Rails.application.config.respond_to?(:enable_reloading=)
106+
["enable_reloading", "true"]
107+
else
108+
["cache_classes", "false"]
109+
end
105110
raise <<-MSG.strip_heredoc
106111
Spring reloads, and therefore needs the application to have reloading enabled.
107-
Please, set config.cache_classes to false in config/environments/#{Rails.env}.rb.
112+
Please, set config.#{config_name} to #{set_to} in config/environments/#{Rails.env}.rb.
108113
MSG
109114
end
110115
end

test/support/acceptance_test.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ def without_gem(name)
144144
end
145145
File.write(config_path, config)
146146

147-
assert_failure "bin/rails runner 1", stderr: "Please, set config.cache_classes to false"
147+
expected_error = Regexp.union(
148+
"Please, set config.enable_reloading to true",
149+
"Please, set config.cache_classes to false"
150+
)
151+
152+
assert_failure "bin/rails runner 1", stderr: expected_error
148153
end
149154

150155
test "test changes are picked up" do

0 commit comments

Comments
 (0)