Skip to content

Commit

Permalink
Use configure blocks to change the sprockets environment
Browse files Browse the repository at this point in the history
sprockets-rails 3 will build the sprockets environment only in a
after_initialize block so app.assets is never defined in a railtie
initializer.
  • Loading branch information
rafaelfranca committed Sep 8, 2015
1 parent 94b5a1d commit c85db78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/sassc/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class Railtie < ::Rails::Railtie
# config.sass.full_exception = app.config.consider_all_requests_local
# end

if app.assets
app.assets.context_class.class_eval do
app.config.assets.configure do |env|
env.context_class.class_eval do
class_attribute :sass_config
self.sass_config = app.config.sass
end

app.assets.register_engine '.sass', SassC::Rails::SassTemplate
app.assets.register_engine '.scss', SassC::Rails::ScssTemplate
env.register_engine '.sass', SassC::Rails::SassTemplate
env.register_engine '.scss', SassC::Rails::ScssTemplate
end
end

Expand Down
4 changes: 3 additions & 1 deletion test/sassc_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def setup
@app.config.sass.line_comments = false

# Add a fake compressor for testing purposes
@app.assets.register_compressor "text/css", :test, TestCompressor
@app.config.assets.configure do |env|
env.register_compressor "text/css", :test, TestCompressor
end

Rails.backtrace_cleaner.remove_silencers!
end
Expand Down

0 comments on commit c85db78

Please sign in to comment.