diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 18 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 9 |
2 files changed, 21 insertions, 6 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 7c590b701e..c403863007 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -145,9 +145,25 @@ module Rails protected + def static_paths + @static_paths ||= begin + static_paths = ActiveSupport::OrderedHash.new + static_paths["/"] = paths.public.to_a.first + + railties.all do |railtie| + if railtie.config.respond_to?(:asset_path) && railtie.config.asset_path + public_path = railtie.config.paths.public.to_a.first + static_paths[railtie.config.asset_path % ""] = public_path if File.exists?(public_path) + end + end + + static_paths + end + end + def default_middleware_stack ActionDispatch::MiddlewareStack.new.tap do |middleware| - middleware.use ::ActionDispatch::Static, paths.public.to_a.first if config.serve_static_assets + middleware.use ::ActionDispatch::Static, static_paths if config.serve_static_assets middleware.use ::Rack::Lock if !config.allow_concurrency middleware.use ::Rack::Runtime middleware.use ::Rails::Rack::Logger diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 49553a57f3..85ff09d2af 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -256,11 +256,7 @@ module Rails end def config - @config ||= begin - config = Engine::Configuration.new(find_root_with_flag("lib")) - config.asset_path = "/#{engine_name}%s" if File.exists?(config.paths.public.to_a.first) - config - end + @config ||= Engine::Configuration.new(find_root_with_flag("lib")) end # Add configured load paths to ruby load paths and remove duplicates. @@ -335,6 +331,9 @@ module Rails require environment if environment end + initializer :default_asset_path do + config.asset_path = "/#{engine_name}%s" unless config.asset_path + end protected def find_root_with_flag(flag, default=nil) root_path = self.class.called_from |