Skip to content

Commit cf86cf7

Browse files
committed
Move assets route internal decoration.
We can't depend on assets_prefix outside sprockets.
1 parent 1548551 commit cf86cf7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/sprockets/rails/route_wrapper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Sprockets
2+
module Rails
3+
module RouteWrapper
4+
def self.included(klass)
5+
klass.class_attribute(:assets_prefix)
6+
klass.class_eval do
7+
def assets_prefix
8+
self.class.assets_prefix
9+
end
10+
11+
def internal_with_sprockets?
12+
internal_without_sprockets? || path =~ %r{\A#{assets_prefix}\z}
13+
end
14+
alias_method_chain :internal?, :sprockets
15+
end
16+
end
17+
end
18+
end
19+
end

lib/sprockets/railtie.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require 'sprockets'
77
require 'sprockets/rails/context'
88
require 'sprockets/rails/helper'
9+
require 'sprockets/rails/route_wrapper'
910
require 'sprockets/rails/version'
1011

1112
module Rails
@@ -146,6 +147,12 @@ def self.build_manifest(app)
146147
end
147148
app.assets_manifest = build_manifest(app)
148149

150+
ActionDispatch::Routing::RouteWrapper.class_eval do
151+
include Sprockets::Rails::RouteWrapper
152+
153+
self.assets_prefix = config.assets.prefix
154+
end
155+
149156
ActiveSupport.on_load(:action_view) do
150157
include Sprockets::Rails::Helper
151158

0 commit comments

Comments
 (0)