From c96382a71a77505ea2f51e43bc81fdb3ac95d117 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 5 Feb 2009 16:39:32 -0600 Subject: Make sure all autoload constants are pulled in when using config.threadsafe! [#1831 state:resolved] --- railties/lib/initializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index da064c86aa..e3811dd8be 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -132,10 +132,10 @@ module Rails add_gem_load_paths require_frameworks - preload_frameworks set_autoload_paths add_plugin_load_paths load_environment + preload_frameworks initialize_encoding initialize_database @@ -270,7 +270,7 @@ module Rails configuration.frameworks.each do |framework| # String#classify and #constantize aren't available yet. toplevel = Object.const_get(framework.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }) - toplevel.load_all! + toplevel.load_all! if toplevel.respond_to?(:load_all!) end end end -- cgit v1.2.3 From 893e9eb99504705419ad6edac14d00e71cef5f12 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 9 Feb 2009 14:20:30 -0600 Subject: Improve view rendering performance in development mode and reinstate template recompiling in production [#1909 state:resolved] Signed-off-by: Joshua Peek --- railties/lib/initializer.rb | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index e3811dd8be..2cc0943b78 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -181,9 +181,6 @@ module Rails # Observers are loaded after plugins in case Observers or observed models are modified by plugins. load_observers - # Load view path cache - load_view_paths - # Load application classes load_application_classes @@ -367,16 +364,6 @@ Run `rake gems:install` to install the missing gems. end end - def load_view_paths - if configuration.frameworks.include?(:action_view) - if configuration.cache_classes - view_path = ActionView::Template::EagerPath.new(configuration.view_path) - ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) - end - end - end - # Eager load application classes def load_application_classes return if $rails_rake_task -- cgit v1.2.3 From 5c63be1f92edcd3ed60fae90b8eb129da19c5099 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 9 Feb 2009 14:53:14 -0600 Subject: Still need to setup view paths --- railties/lib/initializer.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 2cc0943b78..11aa8a534e 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -181,6 +181,9 @@ module Rails # Observers are loaded after plugins in case Observers or observed models are modified by plugins. load_observers + # Load view path cache + load_view_paths + # Load application classes load_application_classes @@ -364,6 +367,15 @@ Run `rake gems:install` to install the missing gems. end end + def load_view_paths + if configuration.frameworks.include?(:action_view) + if configuration.cache_classes + ActionController::Base.view_paths = configuration.view_path if configuration.frameworks.include?(:action_controller) + ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) + end + end + end + # Eager load application classes def load_application_classes return if $rails_rake_task -- cgit v1.2.3 From 1dab1d380377f1a2a60da43bc22989d55632d246 Mon Sep 17 00:00:00 2001 From: Gaspard Bucher Date: Tue, 10 Feb 2009 12:58:32 +0100 Subject: Fixes a typo in initializer.rb producing error: undefined local variable or method `view_path'. --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 11aa8a534e..39140065b0 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -371,7 +371,7 @@ Run `rake gems:install` to install the missing gems. if configuration.frameworks.include?(:action_view) if configuration.cache_classes ActionController::Base.view_paths = configuration.view_path if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) + ActionMailer::Base.template_root = configuration.view_path if configuration.frameworks.include?(:action_mailer) end end end -- cgit v1.2.3 From 199e750d46c04970b5e7684998d09405648ecbd4 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 10 Feb 2009 12:09:49 -0600 Subject: Fix some edge cases when the same template is called with different local assigns Signed-off-by: Joshua Peek --- railties/lib/initializer.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 39140065b0..c4c55a97eb 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -369,10 +369,8 @@ Run `rake gems:install` to install the missing gems. def load_view_paths if configuration.frameworks.include?(:action_view) - if configuration.cache_classes - ActionController::Base.view_paths = configuration.view_path if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.template_root = configuration.view_path if configuration.frameworks.include?(:action_mailer) - end + ActionController::Base.view_paths.each { |path| path.load! } if configuration.frameworks.include?(:action_controller) + ActionMailer::Base.template_root.load! if configuration.frameworks.include?(:action_mailer) end end -- cgit v1.2.3 From 3942cb406e1d5db0ac00e03153809cc8dc4cc4db Mon Sep 17 00:00:00 2001 From: thedarkone Date: Thu, 12 Feb 2009 19:35:14 +0100 Subject: Port fast reloadable templates from rails-dev-boost. --- railties/lib/initializer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index c4c55a97eb..281b074e0a 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -369,8 +369,8 @@ Run `rake gems:install` to install the missing gems. def load_view_paths if configuration.frameworks.include?(:action_view) - ActionController::Base.view_paths.each { |path| path.load! } if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.template_root.load! if configuration.frameworks.include?(:action_mailer) + ActionController::Base.view_paths.load! if configuration.frameworks.include?(:action_controller) + ActionMailer::Base.view_paths.load! if configuration.frameworks.include?(:action_mailer) end end @@ -478,7 +478,7 @@ Run `rake gems:install` to install the missing gems. # set to use Configuration#view_path. def initialize_framework_views if configuration.frameworks.include?(:action_view) - view_path = ActionView::Template::Path.new(configuration.view_path) + view_path = ActionView::PathSet.type_cast(configuration.view_path) ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer) ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty? end -- cgit v1.2.3 From 69c049f5ab45bf9bfb0d269acea0773581905fd4 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 20 Feb 2009 12:04:57 -0600 Subject: Move development mode reloading up the stack to avoid issues with class reloading in middleware --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 281b074e0a..7e1bd23a55 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -583,7 +583,7 @@ Run `rake gems:install` to install the missing gems. return unless configuration.frameworks.include?(:action_controller) require 'dispatcher' unless defined?(::Dispatcher) Dispatcher.define_dispatcher_callbacks(configuration.cache_classes) - Dispatcher.new(Rails.logger).send :run_callbacks, :prepare_dispatch + Dispatcher.run_prepare_callbacks end def disable_dependency_loading -- cgit v1.2.3 From 01c818e99f04f70462df68e6a217dfd280c37581 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Fri, 20 Feb 2009 14:16:07 -0600 Subject: break out of initializer early if gems aren't loaded [#1750 state:resolved] Signed-off-by: Joshua Peek --- railties/lib/initializer.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 7e1bd23a55..8221f1f2f2 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -167,6 +167,10 @@ module Rails load_gems check_gem_dependencies + # bail out if gems are missing - note that check_gem_dependencies will have + # already called abort() unless $gems_rake_task is set + return unless gems_dependencies_loaded + load_application_initializers # the framework is now fully initialized @@ -302,7 +306,7 @@ module Rails if unloaded_gems.size > 0 @gems_dependencies_loaded = false # don't print if the gems rake tasks are being run - unless $rails_rake_task + unless $gems_rake_task abort <<-end_error Missing these required gems: #{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "} -- cgit v1.2.3 From b61cad6ae140bc71c6a74b22c75e886b41154b0a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 22 Feb 2009 16:04:04 +0100 Subject: Ensure that the app routes file is loaded even when engines are in play (Thjis) [#1970 state:committed] --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 8221f1f2f2..eb8d3510c8 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -496,7 +496,7 @@ Run `rake gems:install` to install the missing gems. ActionController::Routing.controller_paths += configuration.controller_paths ActionController::Routing::Routes.add_configuration_file(configuration.routes_configuration_file) - ActionController::Routing::Routes.reload + ActionController::Routing::Routes.reload! end # Sets the dependency loading mechanism based on the value of -- cgit v1.2.3 From 441e4e22352c8805a882f6a661ab3982dd7eda12 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 22 Feb 2009 10:39:56 -0600 Subject: load plugin view_paths to action_mailer view_paths and make action_mailer use them [#2031 state:resolved] Signed-off-by: Joshua Peek --- railties/lib/initializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index eb8d3510c8..0e05634f4a 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -483,8 +483,8 @@ Run `rake gems:install` to install the missing gems. def initialize_framework_views if configuration.frameworks.include?(:action_view) view_path = ActionView::PathSet.type_cast(configuration.view_path) - ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer) - ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty? + ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) && ActionMailer::Base.view_paths.blank? + ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.blank? end end -- cgit v1.2.3 From 53cd102b39eb62567298430cbd94e40dd78d46a0 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 24 Feb 2009 12:29:25 +0000 Subject: Merge with docrails --- railties/lib/initializer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 0e05634f4a..a31ae9422e 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -838,7 +838,8 @@ Run `rake gems:install` to install the missing gems. # Enable threaded mode. Allows concurrent requests to controller actions and # multiple database connections. Also disables automatic dependency loading - # after boot + # 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 -- cgit v1.2.3 From 1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 24 Feb 2009 11:34:32 -0600 Subject: Ensure ActiveRecord session store's connections are checked in after each request [#1927 state:resolved] --- railties/lib/initializer.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index a31ae9422e..09affe9e36 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -176,6 +176,9 @@ module Rails # the framework is now fully initialized after_initialize + # Setup database middleware after initializers have run + initialize_database_middleware + # Prepare dispatcher callbacks and run 'prepare' callbacks prepare_dispatcher @@ -410,7 +413,18 @@ Run `rake gems:install` to install the missing gems. if configuration.frameworks.include?(:active_record) ActiveRecord::Base.configurations = configuration.database_configuration ActiveRecord::Base.establish_connection - configuration.middleware.use ActiveRecord::QueryCache + end + end + + def initialize_database_middleware + if configuration.frameworks.include?(:active_record) + if ActionController::Base.session_store == ActiveRecord::SessionStore + configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::ConnectionAdapters::ConnectionManagement + configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::QueryCache + else + configuration.middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement + configuration.middleware.use ActiveRecord::QueryCache + end end end -- cgit v1.2.3 From 319106d09c0ec2daf8b5345f525f1c97b6368ce2 Mon Sep 17 00:00:00 2001 From: Matthew Rudy Jacobs Date: Sun, 22 Feb 2009 19:23:04 +0000 Subject: Metal can now line in plugins under app/metal [#2045 state:committed] Signed-off-by: David Heinemeier Hansson --- railties/lib/initializer.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 09affe9e36..24ce3e75ff 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -559,6 +559,8 @@ Run `rake gems:install` to install the missing gems. end def initialize_metal + Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths + configuration.middleware.insert_before( :"ActionController::RewindableInput", Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?) -- cgit v1.2.3 From 4d4d2c3896ed5a5d74da833c5c3132f406f4eab7 Mon Sep 17 00:00:00 2001 From: Simon Jefford Date: Tue, 3 Mar 2009 12:39:19 -0600 Subject: Enhanced Rails Metal - the load order of metals can now be configured [#2057 state:resolved] Signed-off-by: Joshua Peek --- railties/lib/initializer.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 24ce3e75ff..edea4e513a 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -559,6 +559,7 @@ Run `rake gems:install` to install the missing gems. end def initialize_metal + Rails::Rack::Metal.requested_metals = configuration.metals Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths configuration.middleware.insert_before( @@ -715,6 +716,11 @@ Run `rake gems:install` to install the missing gems. @plugins = plugins.nil? ? nil : plugins.map { |p| p.to_sym } end + # The list of metals to load. If this is set to nil, all metals will + # be loaded in alphabetical order. If this is set to [], no metals will + # be loaded. Otherwise metals will be loaded in the order specified + attr_accessor :metals + # The path to the root of the plugins directory. By default, it is in # vendor/plugins. attr_accessor :plugin_paths -- cgit v1.2.3 From 99d75a7b02bf430a124b9c3e2515850959d78acf Mon Sep 17 00:00:00 2001 From: David Dollar Date: Fri, 13 Mar 2009 10:20:23 +0000 Subject: Makes the gem system understand development vs. runtime dependencies [#2195 state:resolved] The patch also fixes: * Fixes the chicken/egg problem present in the current gem system when gems are defined in the config that are not yet installed. * Remove the need to have hoe as a dependency of your production app. * Makes the gem 'unpacking' system a lot less fragile. Signed-off-by: Matt Jones Signed-off-by: Pratik Naik --- railties/lib/initializer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'railties/lib/initializer.rb') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index edea4e513a..a04405a7c2 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -301,7 +301,9 @@ module Rails end def load_gems - @configuration.gems.each { |gem| gem.load } + unless $gems_build_rake_task + @configuration.gems.each { |gem| gem.load } + end end def check_gem_dependencies -- cgit v1.2.3