Skip to content

Commit 406a500

Browse files
committed
Eliminate the need for an on_load block
Addreses rails/rails#9461 Given that sprockets-rails/lib/sprockets/railtie.rb contains: require 'sprockets/rails/helper' And sprockets-rails/lib/sprockets/ruby/helper.rb starts out with: require 'action_view' It follows that an on_load hander is not required.
1 parent 8105eb9 commit 406a500

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

lib/sprockets/railtie.rb

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,24 @@ def configure(&block)
8181
app.assets.append_path path
8282
end
8383

84-
ActiveSupport.on_load(:action_view) do
85-
include Sprockets::Rails::Helper
86-
87-
# Copy relevant config to AV context
88-
self.debug_assets = config.assets.debug
89-
self.digest_assets = config.assets.digest
90-
self.assets_prefix = config.assets.prefix
91-
92-
# Copy over to Sprockets as well
93-
context = app.assets.context_class
94-
context.assets_prefix = config.assets.prefix
95-
context.digest_assets = config.assets.digest
96-
context.config = config.action_controller
97-
98-
if config.assets.compile
99-
self.assets_environment = app.assets
100-
self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
101-
else
102-
self.assets_manifest = Sprockets::Manifest.new(manifest_path)
103-
end
84+
include Sprockets::Rails::Helper
85+
86+
# Copy relevant config to AV context
87+
self.debug_assets = config.assets.debug
88+
self.digest_assets = config.assets.digest
89+
self.assets_prefix = config.assets.prefix
90+
91+
# Copy over to Sprockets as well
92+
context = app.assets.context_class
93+
context.assets_prefix = config.assets.prefix
94+
context.digest_assets = config.assets.digest
95+
context.config = config.action_controller
96+
97+
if config.assets.compile
98+
self.assets_environment = app.assets
99+
self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
100+
else
101+
self.assets_manifest = Sprockets::Manifest.new(manifest_path)
104102
end
105103

106104
app.assets.js_compressor = config.assets.js_compressor

0 commit comments

Comments
 (0)