Rails Kitchen Sink
$ git clone git://github.com/recurser/rails-kitchen-sink.git
About
I needed a solid base to build my own rails projects from. Since integrating all these disparate pieces isn’t the easiest thing in the world, I decided to release this sample site in the hope that it would save you some time as well.
The demo application is designed to provide a solid, generic skeleton to base your next rails project on, and includes everything you’ll need to dive straight in and get started.
Demo Site
You can try out a live demo of the project at railskitchensink.com. The database will be automatically re-generated every hour, so don’t be surprised if any changes disappear.
License
This project is distributed under the MIT License. See the License file for details.
Installation
To get started, first download the source via git
> git clone git://recursive-design.com/rails-kitchen-sink.git
> cd rails-kitchen-sink
Next, install the requisite gems:
> gem install bundler
> bundle install
Set up the database:
> rake db:setup
Finally, run the local development server to try it out:
> rails s
The demo application should now be available at http://localhost:3000/.
What’s Included?
I’ve tried to create a sensible base to start build your Rails 3 applications off of, with all the packages I generally use pre-integrated. Rails Kitchen Sink currently combines:
- Devise authentication.
- CanCan authorization.
- HAML templates.
- CoffeeScript support.
- metric_fu reports.
- Full RSpec test suite.
- Spork DRb server.
- 960 CSS grid system.
- Jammit asset packaging.
- Formtastic forms.
Testing
Rails Kitchen Sink comes pre-configured for Spork and autotest support. I generally work by running spork in one terminal:
> cd rails-kitchen-sink
> spork
Using RSpec
Loading Spork.prefork block...
Spork is ready and listening on 8989!
… and running autotest in another:
> cd rails-kitchen-sink
> autotest
........................................................................................
Finished in 29.27 seconds
88 examples, 0 failures
Autotest will run the test suite automatically whenever you save changes, and if you’re working on OSX, it will provide Growl feedback every time the test suite is run:

Deploying To Heroku
To deploy the application to Heroku simply run heroku create:
> heroku create
Creating evening-beach-14... done
Created http://evening-beach-14.heroku.com/ | git@heroku.com:evening-beach-14.git
Git remote heroku added
The evening-beach-14 part will vary depending on the name Heroku chooses for your application.
To push your newly created application to Heroku, do a git push heroku master:
> git push heroku master
Counting objects: 1669, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (629/629), done.
Writing objects: 100% (1669/1669), 382.36 KiB, done.
Total 1669 (delta 955), reused 1657 (delta 949)
-----> Heroku receiving push
-----> Rails app detected
-----> Gemfile detected, running Bundler version 1.0.0
Unresolved dependencies detected; Installing...
Fetching source index for http://rubygems.org/
...
[installing a bunch of gems]
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Your bundle was installed to `.bundle/gems`
Compiled slug size is 25.6MB
-----> Launching.... done
http://evening-beach-14.heroku.com deployed to Heroku
To git@heroku.com:evening-beach-14.git
* [new branch] master -> master
Next, create the database on Heroku:
> heroku rake db:setup
You should also install the free SendGrid add-on for email delivery:
> heroku addons:add sendgrid:free
Your application should now be available at http://evening-beach-14.heroku.com/ (substitute the domain you received from git push heroku here).
Whenever you push changes to git, you can update heroku by doing git push heroku again.
Git hooks
CoffeeScript and Compass both require generated files to be saved when they’re compiled - this causes a problem on Heroku because access to the filesystem is limited. There are various hacks to get around this by saving to the tmp folder and re-routing requests, but I decided it was probably easiest to just add the generated files to git and deploy them normally.
To achieve this, I added a post-commit hook to the repository to generate these files whenever changes are committed. To add these, create the file .git/hooks/pre-commit , make it executable, and add the following contents:
#!/bin/sh
compass compile
rake public/javascripts/application.js
jammit
git add public/assets/common*
git add public/javascripts/application.js
The first two commands generate the CSS and Javascript respectively, the 3rd command packages them up using Jammit, and the last two make sure they are included in the commit.
Internationalization
Rails Kitchen Sink is fully I18N-ready, but unfortunately the only translation is currently (i assume fairly badly) auto-generated-french from Google translate. If you’d like to contribute a translation, you can start by looking at the translation files and static pages. There’s not a great deal of text to translate, so if anyone is feeling particularly generous and/or bored, additional translations would be very much appreciated!
Stylesheets
Stylesheets in the public/stylesheets folder are automatically generated by compass, so any changes you make to these files will be lost. Instead, you should edit the sass files in app/stylesheets.
When altering stylesheets during development, you should run compass watch to make sure your changes are automatically compiled to public/stylesheets:
> compass watch
>>> Compass is watching for changes. Press Ctrl-C to Stop.
Javascript
Similarly, public/javascripts/application.js is automatically generated by the CoffeeScript compiler. Instead of editing it directly, edit application/scripts/application.coffee instead.
Unlike Compass, there is no need to run a watch script for this file during development - it will automatically be compiled for you.
Asset Packaging
JavaScript and CSS are automatically compressed and packaged for production with Jammit. During development, the non-compressed versions will be served to speed things up. This packaging should be fairly transparent to you if you set up the git pre-commit hook described above - if you choose not to do this you will need to run the jammit command manually before committing changes.
Bug Reports
If you come across any problems, please create a ticket and we’ll try to get it fixed as soon as possible.
Contributing
Once you’ve made your commits:
- Fork rails-kitchen-sink
- Create a topic branch -
git checkout -b my_branch - Push to your branch -
git push origin my_branch - Create a Pull Request from your branch
- That’s it!
Author
Dave Perrett :: mail@recursive-design.com :: @recurser
Copyright
Copyright) (c) 2010 Dave Perrett. See License for details.