Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend setting enable_reloading on newer Rails versions #715

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/spring/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,14 @@ def preload

Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
if Rails.application.config.cache_classes
config_name, set_to = if Rails.application.config.respond_to?(:enable_reloading=)
["enable_reloading", "true"]
else
["cache_classes", "false"]
end
raise <<-MSG.strip_heredoc
Spring reloads, and therefore needs the application to have reloading enabled.
Please, set config.cache_classes to false in config/environments/#{Rails.env}.rb.
Please, set config.#{config_name} to #{set_to} in config/environments/#{Rails.env}.rb.
MSG
end
end
Expand Down
7 changes: 6 additions & 1 deletion test/support/acceptance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ def without_gem(name)
end
File.write(config_path, config)

assert_failure "bin/rails runner 1", stderr: "Please, set config.cache_classes to false"
expected_error = Regexp.union(
"Please, set config.enable_reloading to true",
"Please, set config.cache_classes to false"
)

assert_failure "bin/rails runner 1", stderr: expected_error
end

test "test changes are picked up" do
Expand Down
Loading