Search code examples
ruby-on-rails-3.1compass-sass

How to use compass with rails 3.1


I have searched and searched and all I could see was that to use compass with rails 3.1 was to just edit the Gemfile like so:

gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31'
gem 'sass-rails', "~> 3.1.0.rc"

Yes I understand that but what next? Every tutorial I saw said just that, use that certain fork. But I am still having trouble with using compass with rails 3.1.

I did this:

$ compass init rails . --syntax sass
  directory ./app/stylesheets/ 
  create ./config/compass.rb 
  create ./app/stylesheets/screen.sass 
  create ./app/stylesheets/print.sass 
  create ./app/stylesheets/ie.sass

And since 3.1 was using assets now, I just transferred all those files to 3.1. Also, I am using compass-960 plugin, so where do I require it? I tried adding a compass.rb with require 960 and require html5-boilerplate and I still keep getting errors:

Error compiling asset application.css:
NoMethodError: undefined method `Error' for Compass:Module
  (in /Users/eumir/rails_apps/kiseki/app/assets/stylesheets/screen.sass)

NoMethodError (undefined method `Error' for Compass:Module
(in /Users/eumir/rails_apps/kiseki/app/assets/stylesheets/screen.sass)):

I tried doing compass compile and it gave me this:

$ compass compile Nothing to compile. If you're trying to start a new project, you have left off the directory argument. Run "compass -h" to get help.

As I said, I already edited my compass.rb so I am still stumped as to how to go about with this. Any help?


Solution

  • The solutions in the other answers are deprecated with the latest version of Compass, v0.12, which requires an adapter to work with a rails app. The Compass author, Chris Eppstein, has put installation instructions on github:
    https://github.com/compass/compass-rails

    This adapter supports rails versions 2.3 and greater