From 9dbcac78113808da23dfe1e3e7b0cc6a390e03be Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 4 Nov 2014 14:54:52 -0800 Subject: add lib to $LOAD_PATH on application inhertence. fixes #17106 --- railties/lib/rails/engine.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/engine.rb') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index dc3da1eb41..d985518fd9 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -364,6 +364,10 @@ module Rails super end + def find_root(from) + find_root_with_flag "lib", from + end + def endpoint(endpoint = nil) @endpoint ||= nil @endpoint = endpoint if endpoint @@ -531,7 +535,7 @@ module Rails # Define the configuration object for the engine. def config - @config ||= Engine::Configuration.new(find_root_with_flag("lib")) + @config ||= Engine::Configuration.new(self.class.find_root(self.class.called_from)) end # Load data from db/seeds.rb file. It can be used in to load engines' @@ -658,8 +662,7 @@ module Rails paths["db/migrate"].existent.any? end - def find_root_with_flag(flag, default=nil) #:nodoc: - root_path = self.class.called_from + def self.find_root_with_flag(flag, root_path, default=nil) #:nodoc: while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/#{flag}") parent = File.dirname(root_path) -- cgit v1.2.3 From 6f57e1240eed636a6f47f131a9f39360e28a80c4 Mon Sep 17 00:00:00 2001 From: George Millo Date: Mon, 17 Nov 2014 15:26:33 +0700 Subject: Minor English fixes in docs [ci skip] --- railties/lib/rails/engine.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails/engine.rb') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index d985518fd9..023ea98145 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -110,8 +110,8 @@ module Rails # # == Endpoint # - # An engine can be also a rack application. It can be useful if you have a rack application that - # you would like to wrap with +Engine+ and provide some of the +Engine+'s features. + # An engine can also be a rack application. It can be useful if you have a rack application that + # you would like to wrap with +Engine+ and provide with some of the +Engine+'s features. # # To do that, use the +endpoint+ method: # -- cgit v1.2.3 From f2b17231bacbbc437f64b51b386b3eea06c65c84 Mon Sep 17 00:00:00 2001 From: Alexander Mankuta Date: Wed, 26 Nov 2014 13:47:09 +0200 Subject: Use absolute_path of caller_locations to infer engine root According to documentation `path` only returns file names. On MRI it's not the case but it's likely a bug in MRI. --- railties/lib/rails/engine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails/engine.rb') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 023ea98145..4b7da32208 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -351,7 +351,7 @@ module Rails base.called_from = begin call_stack = if Kernel.respond_to?(:caller_locations) - caller_locations.map(&:path) + caller_locations.map(&:absolute_path) else # Remove the line number from backtraces making sure we don't leave anything behind caller.map { |p| p.sub(/:\d+.*/, '') } -- cgit v1.2.3