diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-07-29 16:23:15 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:09 +0200 |
commit | 937f41919c6033272b40b147f7ac5e888207ac89 (patch) | |
tree | ea2716296619f713aba94507a124a489b5cff00a /railties/lib/rails | |
parent | 401cd97923fb52c8f8c458b8cb276b338e0b20f3 (diff) | |
download | rails-937f41919c6033272b40b147f7ac5e888207ac89.tar.gz rails-937f41919c6033272b40b147f7ac5e888207ac89.tar.bz2 rails-937f41919c6033272b40b147f7ac5e888207ac89.zip |
Engine's assets are now served with ActionDispatch::Static
Diffstat (limited to 'railties/lib/rails')
-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 |