Skip to content

Commit f9eee79

Browse files
swisenermanheim-swisener
authored andcommitted
Respect Rails.public_path when computing the path to the manifest file.
This is important when packaging JRuby apps using warbler, as the public directory configured to be the root of the war file, rather than underneath a directory called "public".
1 parent 1802687 commit f9eee79

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/sprockets/railtie.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
require 'rails'
24
require 'rails/railtie'
35
require 'action_controller/railtie'
@@ -64,7 +66,7 @@ def configure(&block)
6466
config.after_initialize do |app|
6567
config = app.config
6668

67-
manifest_path = File.join(app.root, 'public', config.assets.prefix)
69+
manifest_path = File.join(::Rails.public_path, config.assets.prefix)
6870

6971
unless config.assets.version.blank?
7072
app.assets.version += "-#{config.assets.version}"

test/test_railtie.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,13 @@ def test_sprockets_context_helper
162162
assert_equal false, env.context_class.digest_assets
163163
assert_equal nil, env.context_class.config.asset_host
164164
end
165+
166+
def test_manifest_path_respects_rails_public_path
167+
app.configure do
168+
config.paths['public'] = 'test_public'
169+
end
170+
app.initialize!
171+
172+
assert_match %r{test_public/assets/manifest-.*.json}, ActionView::Base.assets_manifest.path
173+
end
165174
end

0 commit comments

Comments
 (0)