aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-29 19:23:31 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-29 19:23:31 -0800
commit9e4621d6f7b7e864c6463da065f17b8ee27ecb81 (patch)
tree1fed9f750487916d70d4bd8d5c484ed0e001e852 /railties/lib
parent8521cebbad465ae0acba36bda3fd202a898d194a (diff)
parent1182658e767d2db4a46faed35f0b1075c5dd9a88 (diff)
downloadrails-9e4621d6f7b7e864c6463da065f17b8ee27ecb81.tar.gz
rails-9e4621d6f7b7e864c6463da065f17b8ee27ecb81.tar.bz2
rails-9e4621d6f7b7e864c6463da065f17b8ee27ecb81.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb23
-rw-r--r--railties/lib/rails/backtrace_cleaner.rb4
-rw-r--r--railties/lib/rails/plugin.rb11
-rw-r--r--railties/lib/rails/plugin/loader.rb34
4 files changed, 40 insertions, 32 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index b0abf3379c..8e8bcf21fe 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -48,12 +48,8 @@ module Rails
end
end
- def root
- if defined?(RAILS_ROOT)
- RAILS_ROOT
- else
- nil
- end
+ def root(*args)
+ File.join(RAILS_ROOT, *args.compact) if defined?(RAILS_ROOT)
end
def env
@@ -372,9 +368,10 @@ Run `rake gems:install` to install the missing gems.
def load_view_paths
if configuration.frameworks.include?(:action_view)
- ActionView::PathSet::Path.eager_load_templates! if configuration.cache_classes
- ActionController::Base.view_paths.load if configuration.frameworks.include?(:action_controller)
- ActionMailer::Base.template_root.load if configuration.frameworks.include?(:action_mailer)
+ if configuration.cache_classes
+ ActionController::Base.view_paths.load if configuration.frameworks.include?(:action_controller)
+ ActionMailer::Base.template_root.load if configuration.frameworks.include?(:action_mailer)
+ end
end
end
@@ -487,12 +484,8 @@ Run `rake gems:install` to install the missing gems.
def initialize_routing
return unless configuration.frameworks.include?(:action_controller)
- ActionController::Routing.controller_paths = configuration.controller_paths + plugin_loader.controller_paths
-
- ([ configuration.routes_configuration_file ] + plugin_loader.routing_files).each do |routing_file|
- ActionController::Routing::Routes.add_configuration_file(routing_file)
- end
-
+ ActionController::Routing.controller_paths += configuration.controller_paths
+ ActionController::Routing::Routes.add_configuration_file(configuration.routes_configuration_file)
ActionController::Routing::Routes.reload
end
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index 82537d962f..d8626aaf14 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -3,11 +3,11 @@ module Rails
ERB_METHOD_SIG = /:in `_run_erb_.*/
VENDOR_DIRS = %w( vendor/plugins vendor/gems vendor/rails )
- MONGREL_DIRS = %w( lib/mongrel bin/mongrel )
+ SERVER_DIRS = %w( lib/mongrel bin/mongrel lib/rack )
RAILS_NOISE = %w( script/server )
RUBY_NOISE = %w( rubygems/custom_require benchmark.rb )
- ALL_NOISE = VENDOR_DIRS + MONGREL_DIRS + RAILS_NOISE + RUBY_NOISE
+ ALL_NOISE = VENDOR_DIRS + SERVER_DIRS + RAILS_NOISE + RUBY_NOISE
def initialize
super
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index 2b1e877e2b..4901abe808 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -71,6 +71,11 @@ module Rails
File.exist?(routing_file)
end
+
+ def view_path
+ File.join(directory, 'app', 'views')
+ end
+
def controller_path
File.join(directory, 'app', 'controllers')
end
@@ -95,11 +100,7 @@ module Rails
def app_paths
- [
- File.join(directory, 'app', 'models'),
- File.join(directory, 'app', 'controllers'),
- File.join(directory, 'app', 'helpers')
- ]
+ [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path ]
end
def lib_path
diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb
index f08d9b74e2..be81bdf4fa 100644
--- a/railties/lib/rails/plugin/loader.rb
+++ b/railties/lib/rails/plugin/loader.rb
@@ -39,6 +39,8 @@ module Rails
register_plugin_as_loaded(plugin)
end
+ configure_engines
+
ensure_all_registered_plugins_are_loaded!
end
@@ -63,19 +65,31 @@ module Rails
$LOAD_PATH.uniq!
end
- # Returns an array of all the controller paths found inside engine-type plugins.
- def controller_paths
- engines.collect(&:controller_path)
- end
-
- # Returns an array of routing.rb files from all the plugins that include config/routes.rb
- def routing_files
- plugins.select(&:routed?).collect(&:routing_file)
- end
-
protected
+ def configure_engines
+ if engines.any?
+ add_engine_routing_configurations
+ add_engine_controller_paths
+ add_engine_view_paths
+ end
+ end
+ def add_engine_routing_configurations
+ engines.select(&:routed?).collect(&:routing_file).each do |routing_file|
+ ActionController::Routing::Routes.add_configuration_file(routing_file)
+ end
+ end
+
+ def add_engine_controller_paths
+ ActionController::Routing.controller_paths += engines.collect(&:controller_path)
+ end
+
+ def add_engine_view_paths
+ # reverse it such that the last engine can overwrite view paths from the first, like with routes
+ ActionController::Base.view_paths += ActionView::PathSet.new(engines.collect(&:view_path).reverse)
+ end
+
# The locate_plugins method uses each class in config.plugin_locators to
# find the set of all plugins available to this Rails application.
def locate_plugins