aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-23 10:41:28 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-23 10:41:28 -0500
commit97a954bf1dd05e79a873bffc94fcf5420b807371 (patch)
tree76f072b03526a4a46799a56e62bbd2950cea1570
parentdb1bac796e2d53fac4b51a3f560010b8f663fb54 (diff)
downloadrails-97a954bf1dd05e79a873bffc94fcf5420b807371.tar.gz
rails-97a954bf1dd05e79a873bffc94fcf5420b807371.tar.bz2
rails-97a954bf1dd05e79a873bffc94fcf5420b807371.zip
Load view path cache after plugins and gems.
-rw-r--r--actionpack/lib/action_view/paths.rb18
-rw-r--r--railties/lib/initializer.rb13
2 files changed, 25 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb
index 9cb50ab4f8..a37706faee 100644
--- a/actionpack/lib/action_view/paths.rb
+++ b/actionpack/lib/action_view/paths.rb
@@ -27,11 +27,10 @@ module ActionView #:nodoc:
attr_reader :path, :paths
delegate :to_s, :to_str, :hash, :inspect, :to => :path
- def initialize(path)
+ def initialize(path, load = true)
raise ArgumentError, "path already is a Path class" if path.is_a?(Path)
-
@path = path.freeze
- reload!
+ reload! if load
end
def ==(path)
@@ -46,6 +45,14 @@ module ActionView #:nodoc:
@paths[path]
end
+ def loaded?
+ @loaded ? true : false
+ end
+
+ def load
+ reload! unless loaded?
+ end
+
# Rebuild load path directory cache
def reload!
@paths = {}
@@ -59,6 +66,7 @@ module ActionView #:nodoc:
end
@paths.freeze
+ @loaded = true
end
private
@@ -71,6 +79,10 @@ module ActionView #:nodoc:
end
end
+ def load
+ each { |path| path.load }
+ end
+
def reload!
each { |path| path.reload! }
end
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 828d688475..97bb81a3c8 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -168,6 +168,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
@@ -333,6 +336,12 @@ Run `rake gems:install` to install the missing gems.
end
end
+ def load_view_paths
+ ActionView::PathSet::Path.eager_load_templates! if configuration.cache_classes
+ ActionMailer::Base.template_root.load
+ ActionController::Base.view_paths.load
+ end
+
# Eager load application classes
def load_application_classes
if configuration.cache_classes
@@ -428,9 +437,7 @@ Run `rake gems:install` to install the missing gems.
# paths have already been set, it is not changed, otherwise it is
# set to use Configuration#view_path.
def initialize_framework_views
- ActionView::PathSet::Path.eager_load_templates! if configuration.cache_classes
- view_path = ActionView::PathSet::Path.new(configuration.view_path)
-
+ view_path = ActionView::PathSet::Path.new(configuration.view_path, false)
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