From 9a37fd44cb7df94d7b7652d03251bb6cd0675b45 Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Mon, 21 Nov 2005 05:55:35 +0000 Subject: Add plugin library directories to the load path after the lib directory so that libraries in the lib directory get precedence. Closes #2910. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3122 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/initializer.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 81578e484e..6287f0ddc1 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -299,9 +299,13 @@ module Rails has_lib = File.directory?(lib_path) has_init = File.file?(init_path) - # Add lib to load path. - $LOAD_PATH.unshift(lib_path) if has_lib - + # Add lib to load path *after* the application lib, to allow + # application libraries to override plugin libraries. + if has_lib + application_lib_index = $LOAD_PATH.index(File.join(RAILS_ROOT, "lib")) || 0 + $LOAD_PATH.insert(application_lib_index + 1, lib_path) + end + # Allow plugins to reference the current configuration object config = configuration -- cgit v1.2.3