Setting up Compass Rails 3.1 Image

Setting up Compass Rails 3.1

November 20, 2011

We’ve been using Haml and Sass ever since. Haml and Sass is great and pretty easy to setup. Here are the steps how:


Step 1: Add this to Gemfile


gem 'compass', '~> 0.12.alpha'


Step 2: Add this to your config/application.rb


stylesheets_directory = "#{Rails.root}/app/assets/stylesheets"
config.assets.precompile += Dir.glob("#{stylesheets_directory/**/*.s[ac]ss*}")

map{ |f| f[stylesheets_directory.size+1..-1]}.select do |f|
  if config.assets.precompile.include?(file)
    false
  elsif File.basename(file)[0..1] == "_"
    false
  else
    true
  end
end

# if you prefer '.sass' over '.scss'.
config.sass.preferred_syntax = :sass


Step 3: Add this to assets/stylesheets/application.css


= require_self
= require blueprint
= require_directory '.'


Step 4: Smile! Your done setting up Compass with Rails 3.1