Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Resurrect threadsafe!

  • Loading branch information...
commit ce9d9fda77e6b8ca0ac64e528af1892a5d508636 1 parent 042bd0a
Yehuda Katz + Carl Lerche authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 railties/lib/initializer.rb
View
12 railties/lib/initializer.rb
@@ -170,6 +170,18 @@ def set_root_path!
RAILS_ROOT.replace self.root_path
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!
+ self.preload_frameworks = true
+ self.cache_classes = true
+ self.dependency_loading = false
+ self.action_controller.allow_concurrency = true
+ self
+ end
+
def framework_paths
paths = %w(railties railties/lib activesupport/lib)
paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view)
Please sign in to comment.
Something went wrong with that request. Please try again.