Skip to content

Instantly share code, notes, and snippets.

@jfreeze
Created March 5, 2011 23:53
Show Gist options
  • Save jfreeze/856841 to your computer and use it in GitHub Desktop.
Save jfreeze/856841 to your computer and use it in GitHub Desktop.
Rails 3 Setup for HAML, SASS, Compass and jQuery

Rails 3 Setup for HAML, SASS, Compass and jQuery

Create new project

rails new project_name
cd project_name

Add Gems to Gemfile

Add the following to Gemfile

gem ‘haml’
gem ‘haml-rails’
gem ‘jquery-rails’
gem ‘compass’

Configure Bundler

mkdir .bundle
touch .bundle/config
vim .bundle/config

Paste the following into config:


BUNDLE_DISABLE_SHARED_GEMS: “1”
BUNDLE_WITHOUT: ""
BUNDLE_PATH: project_gems/
BUNDLE_BIN: bin

Install bundles and bins

bundle install
bundle —binstubs

Install jQuery

./bin/rails generate jquery:install —ui —version 1.5.1 -f

Init Compass

./bin/compass init rails .

Answer (Y) and (n) to the next questions.

Create Default Layout

vim app/views/layouts/application.html.haml

and paste in the following:

!!!
%head
  %title Project Title
  = stylesheet_link_tag 'screen.css', :media => 'screen, projection'
  = stylesheet_link_tag 'print.css', :media => 'print'
  /[if IE]
    = stylesheet_link_tag 'ie.css', :media => 'screen, projection'

  = javascript_include_tag :defaults
  = csrf_meta_tag

%html
  %body
    = yield

Remove erb layout

rm app/views/layouts/application.html.erb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment