3
votes

I am generally confused about Rails 3.2, Sprockets, and Compass.

  1. At the top of this article, it says *= require directives, are no longer needed using Sass-Rails, just use @import instead. The Sass-Rails Github talks about a little about glob @import feature, but doesn't talk at all about @import being the new *= require. Which one or combo :( do I use?

  2. Having coderay.css.sass in vendor/assets/stylesheets and using @import in application.css.sass will import my_coderay.css.sass? I don't know because I'm using Compass Mixins in my_coderay.css.sass (thus putting a @import "compass/css3" at the top of that file) and I'm getting an error:
    "File to import not found or unreadable: compass"

  3. In this article it talks about configuring Rail's Sass engine to know about the assets path. But I thought Sass-Rails already teaches @import where asset path is?

    Also when I try to include the 31 branch of compass...

    gem 'compass', :git => 'git://github.com/chriseppstein/compass.git', :branch => 'rails31'

    I get errors...
    Using compass (0.12.0.alpha.0.22e2458) from git://github.com/chriseppstein/compass.git (at rails31) /Users/george.norris/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:365:in `initialize': No such file or directory - /Users/george.norris/.rvm/gems/ruby-1.9.2-p180/bundler/gems/gems/compass-0.12.0.alpha.0.22e2458/bin/compass (Errno::ENOENT)

  4. And finally, if I take coderay.css.sass out of vendor/assets and put it in app/assets I don't get the above error. But I getting it's spitting out errors in public/application.css.css (.css.css ???)

    Syntax error: File to import not found or unreadable: base. Load paths: Compass::SpriteImporter /Users/geonorr/Sites/quasar/public/stylesheets/sass /Users/geonorr/Sites/quasar/app/assets/stylesheets /Users/geonorr/.rvm/gems/ruby-1.9.2-p180/gems/compass-0.11.5/frameworks/blueprint/stylesheets /Users/geonorr/.rvm/gems/ruby-1.9.2-p180/gems/compass-0.11.5/frameworks/compass/stylesheets on line 3 of /Users/geonorr/Sites/quasar/app/

I am using Rails (3.1.0), Sass (3.1.7), Sass-Rails (3.1.0), Compass (0.11.5)


Thanks for the response. Feel like I am getting closer...
Including Compass Master Branch and getting this error:

gem 'compass', :git => 'git://github.com/chriseppstein/compass', :branch => 'master'

Using compass (0.12.alpha.0.d03d529) from git://github.com/chriseppstein/compass (at master) /Users/gnee/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:365:in initialize': No such file or directory - /Users/gnee/.rvm/gems/ruby-1.9.2-p180/bundler/gems/gems/compass-0.12.alpha.0.d03d529/bin/compass (Errno::ENOENT) from /Users/gnee/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:365:inopen' from /Users/gnee/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:365:in shebang' from /Users/gnee/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:456:inapp_script_text'

1
FYI, the compass rails 3.1 branch disappeared. It's very difficult to find information regarding what's happening with this project.twmills
Ok thats why bundler was failing. Yep all the information on this project is seems deprecated.GN.

1 Answers

3
votes
  1. *= require comments can be seen as a hacky workaround from the perspective of Sass, because Sass has a dedicated language feature for that: the @import directive. @import tells Sprockets what to do. When you are migrating from a Rails 3.0 project, leave all @import statements as they are. At the moment, the only gotcha is "globbing": How to tell Rails/Sprockets to regard also other Sass files than application.css.s(ac)ss.

    Here is the latest Compass installation guide for Rails 3.1. It also tackles the globbing problem.

  2. As it is said in the Rails Guide, app/assets, lib/assets or vendor/assets directories in your app as well as in your gems/engines are included in Rails.application.config.assets.paths. I verified that +opacity(.5) from the compass/css3 library works as expected if you install compass properly. Which leads us to the next point:

  3. The rails31 branch is merged into master now and version 0.12.alpha has been released that should support Rails 3.1. However, this is version is not yet without bugs. So I recommend to rely on the newest master revision:

    gem 'compass', git: 'git://github.com/chriseppstein/compass', branch: 'master'

  4. The only bug I am encountering at the moment is a "undefined method nil.[]" Exception when trying to compile statements that create sprites. See this issue. A workaround for that is to set sass_options = {quite: true} in your config/compass.rb

Further note: I do not have Sass in my Gemfile any more. I think you can remove that dependency when relying on sass-rails.