Skip to content

Instantly share code, notes, and snippets.

@mattbrictson
Created January 26, 2012 23:02
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbrictson/1685685 to your computer and use it in GitHub Desktop.
Save mattbrictson/1685685 to your computer and use it in GitHub Desktop.
Install Compass in Rails 3.1/3.2
# Precompile *all* assets, except those that start with underscore
config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
/*
* application.scss
*
* Important! Do *not* use Sprockets "require" syntax.
* Use @import to include other stylesheets and Compass mixins.
*/
// Include some nice mixins
@import "compass/css3";
@import "sassy-buttons";
// Example: import partial stylesheet named "_users.scss"
@import "users";
# config/compass.rb
additional_import_paths = ["app/assets/stylesheets/basics", "app/assets/stylesheets/shared"]
A ActionView::Template::Error occurred in sessions#new:
1024.css isn't precompiled
.bundle/bundle/gems/actionpack-3.2.0/lib/sprockets/helpers/rails_helper.rb:142:in `digest_for'
.logo
{
background: image-url("logo-small.png") no-repeat;
}
group :assets do
gem 'compass-rails','~> 1.0.0.rc.2'
gem 'compass-colors'
gem 'sassy-buttons'
gem 'sass-rails', '~> 3.2.3'
# non-compass gems omitted for brevity
end
$ bundle exec rake assets:precompile
/Users/mbrictson/.rbenv/versions/1.9.3-p0/bin/ruby script/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Undefined variable: "$body-text-line-height".
(in /Users/mbrictson/Work/rails-project/app/assets/stylesheets/basics/_grid.scss)
Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/mbrictson/.rbenv/versions/1.9.3-p0/...]
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
.
├── Gemfile
├── app
│ └── assets
│ ├── images
│ │ └── logo-small.png
│ ├── javascripts
│ │ └── application.js
│ └── stylesheets
│ ├── _users.scss
│ └── application.scss
└── config
├── application.rb
└── compass.rb
@mattbrictson
Copy link
Author

@siefca, yes, the config.assets.compile=true setting is problematic in production. Usually you will not want to do this. If you have good reason to set config.assets.compile=true, then you will need to ensure the asset pipeline gems are loaded.

I actually describe this in detail in the following blog post (see the config.assets.compile section):

http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-3-configuration/

@siefca
Copy link

siefca commented Mar 30, 2012

@mbrictson: That;s true. I'm just using it as a workaround, since rake assets:precompile takes sometimes up to 10 minutes with Sprockets and Compass.

@itguy51
Copy link

itguy51 commented Oct 12, 2012

Just a note, but in 'application.scss', @import "sassybuttons" should be @import "sassy-buttons" as per jhardy/Sassy-Buttons#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment