aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r--railties/lib/rails/engine.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 72bfe207d7..1d81e08cd3 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -207,7 +207,7 @@ module Rails
# end
# end
#
- # == Namespaced Engine
+ # == Isolated Engine
#
# Normally when you create controllers, helpers and models inside engine, they are treated
# as they were created inside the application. This means all applications helpers and named routes
@@ -324,11 +324,12 @@ module Rails
# MyEngine::Engine.load_seed
#
class Engine < Railtie
- autoload :Configurable, "rails/engine/configurable"
autoload :Configuration, "rails/engine/configuration"
+ autoload :Railties, "rails/engine/railties"
class << self
attr_accessor :called_from, :isolated
+ alias :isolated? :isolated
alias :engine_name :railtie_name
def inherited(base)
@@ -362,15 +363,18 @@ module Rails
_railtie
end
- define_method(:table_name_prefix) do
- "#{name}_"
+ unless mod.respond_to?(:table_name_prefix)
+ define_method(:table_name_prefix) do
+ "#{name}_"
+ end
end
end
end
end
- def isolated?
- !!isolated
+ # Finds engine with given path
+ def find(path)
+ Rails::Engine::Railties.engines.find { |r| File.expand_path(r.root.to_s) == File.expand_path(path.to_s) }
end
end
@@ -495,7 +499,7 @@ module Rails
end
initializer :append_asset_paths do
- config.asset_path ||= "/#{railtie_name}%s"
+ config.asset_path ||= default_asset_path
public_path = paths["public"].first
if config.compiled_asset_path && File.exist?(public_path)
@@ -549,6 +553,11 @@ module Rails
end
protected
+
+ def default_asset_path
+ "/#{railtie_name}%s"
+ end
+
def routes?
defined?(@routes)
end