diff options
author | José Valim <jose.valim@gmail.com> | 2012-08-01 21:10:55 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-08-21 14:47:43 -0300 |
commit | 5d416b907864d99af55ebaa400fff217e17570cd (patch) | |
tree | afebd6f3049f0899aa4bec372f055e301fbceb41 /railties | |
parent | 2801786e1a51b7cf7d7c3fd72b5fc9974f83f435 (diff) | |
download | rails-5d416b907864d99af55ebaa400fff217e17570cd.tar.gz rails-5d416b907864d99af55ebaa400fff217e17570cd.tar.bz2 rails-5d416b907864d99af55ebaa400fff217e17570cd.zip |
Deprecate config.threadsafe!
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 7 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 21 |
3 files changed, 14 insertions, 16 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 851f41249a..fea18b5f47 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -5,6 +5,8 @@ default_url_options[:script_name] to set proper application's mount point by yourself. *Piotr Sarnacki* +* `config.threadsafe!` is deprecated in favor of `config.eager_load` which provides a more fine grained control on what is eager loaded *José Valim* + * The migration generator will now produce AddXXXToYYY/RemoveXXXFromYYY migrations with references statements, for instance rails g migration AddReferencesToProducts user:references supplier:references{polymorphic} diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 5c7cf412ac..7f05b2e7e1 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -90,11 +90,10 @@ module Rails end end - # Enable threaded mode. Allows concurrent requests to controller actions and - # multiple database connections. Also disables automatic dependency loading - # after boot, and disables reloading code on every request, as these are - # fundamentally incompatible with thread safety. def threadsafe! + ActiveSupport::Deprecation.warn "config.threadsafe! is deprecated. Rails applications " \ + "behave by default as thread safe in production as long as config.cache_classes and " \ + "config.eager_load are set to true" @cache_classes = true @eager_load = true self diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 26f8aad95b..ebdbbaee8b 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -139,23 +139,19 @@ module ApplicationTests assert_instance_of Pathname, Rails.root end - test "marking the application as threadsafe sets the correct config variables" do + test "initialize an eager loaded, cache classes app" do add_to_config <<-RUBY - config.threadsafe! + config.eager_load = true + config.cache_classes = true RUBY require "#{app_path}/config/application" - assert AppTemplate::Application.config.cache_classes - assert AppTemplate::Application.config.eager_load + assert AppTemplate::Application.initialize! end - test "initialize a threadsafe app" do - add_to_config <<-RUBY - config.threadsafe! - RUBY - + test "application is always added to eager_load namespaces" do require "#{app_path}/config/application" - assert AppTemplate::Application.initialize! + assert AppTemplate::Application, AppTemplate::Application.config.eager_load_namespaces end test "asset_path defaults to nil for application" do @@ -163,10 +159,11 @@ module ApplicationTests assert_equal nil, AppTemplate::Application.config.asset_path end - test "the application can be marked as threadsafe when there are no frameworks" do + test "the application can be eager loaded even when there are no frameworks" do FileUtils.rm_rf("#{app_path}/config/environments") add_to_config <<-RUBY - config.threadsafe! + config.eager_load = true + config.cache_classes = true RUBY use_frameworks [] |