Skip to content

Commit c85db78

Browse files
committed
Use configure blocks to change the sprockets environment
sprockets-rails 3 will build the sprockets environment only in a after_initialize block so app.assets is never defined in a railtie initializer.
1 parent 94b5a1d commit c85db78

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/sassc/rails/railtie.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class Railtie < ::Rails::Railtie
4444
# config.sass.full_exception = app.config.consider_all_requests_local
4545
# end
4646

47-
if app.assets
48-
app.assets.context_class.class_eval do
47+
app.config.assets.configure do |env|
48+
env.context_class.class_eval do
4949
class_attribute :sass_config
5050
self.sass_config = app.config.sass
5151
end
5252

53-
app.assets.register_engine '.sass', SassC::Rails::SassTemplate
54-
app.assets.register_engine '.scss', SassC::Rails::ScssTemplate
53+
env.register_engine '.sass', SassC::Rails::SassTemplate
54+
env.register_engine '.scss', SassC::Rails::ScssTemplate
5555
end
5656
end
5757

test/sassc_rails_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def setup
2222
@app.config.sass.line_comments = false
2323

2424
# Add a fake compressor for testing purposes
25-
@app.assets.register_compressor "text/css", :test, TestCompressor
25+
@app.config.assets.configure do |env|
26+
env.register_compressor "text/css", :test, TestCompressor
27+
end
2628

2729
Rails.backtrace_cleaner.remove_silencers!
2830
end

0 commit comments

Comments
 (0)