Skip to content

Commit

Permalink
Recommend setting enable_reloading on newer Rails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nvasilevski committed Apr 18, 2024
1 parent 2380451 commit b6dc87e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit b6dc87e

Please sign in to comment.