aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/CHANGELOG3
-rw-r--r--railties/lib/initializer.rb10
2 files changed, 10 insertions, 3 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index e839464ee4..f6dfa85fb3 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,4 +1,7 @@
*SVN*
+
+* Add plugin library directories to the load path after the lib directory so that libraries in the lib directory get precedence. #2910. [james.adam@gmail.com]
+
* Make help for the console command more explicit about how to specify the desired environment in which to run the console. #2911. [anonymous]
* PostgreSQL: the purge_test_database Rake task shouldn't explicitly specify the template0 template when creating a fresh test database. #2964 [dreamer3@gmail.com]
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