From b52d19ff13f546c2afff2792b271289a9143454f Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 20 Jan 2015 13:16:59 -0800 Subject: [PATCH 1/3] Define append_assets_path unless it exists --- lib/sprockets/railtie.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/sprockets/railtie.rb b/lib/sprockets/railtie.rb index f5e92a9e..40e2471b 100644 --- a/lib/sprockets/railtie.rb +++ b/lib/sprockets/railtie.rb @@ -36,6 +36,17 @@ def assets # Returns Sprockets::Manifest for app config. attr_accessor :assets_manifest end + + class Engine < Railtie + # Skip defining append_assets_path on Rails <= 4.2 + unless initializers.find { |init| init.name == :append_assets_path } + initializer :append_assets_path, group: :all do |app| + app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) + app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) + app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) + end + end + end end module Sprockets From 51cded7e98638ba7beefd696d51d17db29732efa Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 20 Jan 2015 13:22:35 -0800 Subject: [PATCH 2/3] Stick with 1.8 syntax --- lib/sprockets/railtie.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sprockets/railtie.rb b/lib/sprockets/railtie.rb index 40e2471b..778f6723 100644 --- a/lib/sprockets/railtie.rb +++ b/lib/sprockets/railtie.rb @@ -40,7 +40,7 @@ def assets class Engine < Railtie # Skip defining append_assets_path on Rails <= 4.2 unless initializers.find { |init| init.name == :append_assets_path } - initializer :append_assets_path, group: :all do |app| + initializer :append_assets_path, :group => :all do |app| app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) From 550dee19751b1197417619c7eb58f5060347ded2 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 20 Jan 2015 13:26:28 -0800 Subject: [PATCH 3/3] Hack for old rails without existent_directories --- lib/sprockets/railtie.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/sprockets/railtie.rb b/lib/sprockets/railtie.rb index 778f6723..010fa4d6 100644 --- a/lib/sprockets/railtie.rb +++ b/lib/sprockets/railtie.rb @@ -41,9 +41,15 @@ class Engine < Railtie # Skip defining append_assets_path on Rails <= 4.2 unless initializers.find { |init| init.name == :append_assets_path } initializer :append_assets_path, :group => :all do |app| - app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) - app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) - app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) + if paths["app/assets"].respond_to?(:existent_directories) + app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) + app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) + app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) + else + app.config.assets.paths.unshift(*paths["vendor/assets"].paths.select { |d| File.directory?(d) }) + app.config.assets.paths.unshift(*paths["lib/assets"].paths.select { |d| File.directory?(d) }) + app.config.assets.paths.unshift(*paths["app/assets"].paths.select { |d| File.directory?(d) }) + end end end end