Search code examples
ruby-on-railsruby-on-rails-3.2sassasset-pipelinecompass-sass

compass-rails isn't letting me do @import compass/reset


I'm getting this error when I start my application:

File to import not found or unreadable: compass/reset.
Load path: /Users/nbenes/projects/lawgical_admin
  (in /Users/nbenes/projects/lawgical_admin/app/assets/stylesheets/screen.css.sass)

(stacktrace:)

app/assets/stylesheets/screen.css.sass:2
app/views/layouts/login.html.haml:7:in `_app_views_layouts_login_html_haml__1550030126632827390_2194381580'

The file that's raising the error starts like this:

app/assets/screen.css.sass

// This import applies a global reset to any page that imports this stylesheet.
@import compass/reset

It's crashing on that import line and I am not sure how to get it to see the compass gem.

My gemfile has this:

Gemfile

group :assets do
  gem 'sass-rails', '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'compass-rails'
end

Compass configuration is barebones:

config/compass.rb

# Require any additional compass plugins here.
project_type = :rails

And finally, the stylesheet gets pulled into the view:

app/views/layouts/login.html.haml

= stylesheet_link_tag 'screen', :media => 'screen, projection'

Somehow it's just not seeing compass or importing it. I tried skipping the compass/reset import but then it dies later at @import blueprint

For some context, I am in the process of upgrading this app to rails 3.2 and to use the asset pipeline instead of Jammit to compile assets (Jammit gem and configuration files were deleted). Any idea what's going wrong? :(


Solution

  • Turns out I missed a very small but very important change to config/application.rb when upgrading from Rails 3.0.x to Rails 3.2.x

    In rails 3 there's a line that reads:

    Bundler.require(:default, Rails.env) if defined?(Bundler)
    

    Which I failed to upgrade to read as follows:

    if defined?(Bundler)
      # If you precompile assets before deploying to production, use this line
      Bundler.require(*Rails.groups(:assets => %w(development test)))
      # If you want your assets lazily compiled in production, use this line
      # Bundler.require(:default, :assets, Rails.env)   
    end