Skip to navigation

A clean slate, Edge Rails recipe

Published December 07, 2006

Having created a few new Rails apps lately I thought I’d document my process of getting a new Edge Rails project, ready for development.

Smile

The following is my recipe for creating a new application we’ll call “idol.” Obviously this whole thing is specific to the tools I use and how I like things set up, so firstly Ill just lay out my tools of choice: subversion, piston, mysql5 client and capistrano.

Without further ado, here tis:


mkdir idol
cd idol

  1. Checkout edge rails
    svn co http://dev.rubyonrails.com/svn/rails/trunk rails
  1. Create new rails app using edge rails
    ruby rails/railties/bin/rails idol
    rm -Rf rails
    rm idol/log/*
  1. Prepare app for initial SVN
    mv idol trunk
    mkdir files branches tags
    svn import . https://dev.aviditybytes.com/svn/idol -m “Initial import of project”
  1. Remove local and check out working copy
    rm -Rf *
    svn co https://dev.aviditybytes.com/svn/idol/trunk
    svn co https://dev.aviditybytes.com/svn/idol/files
  1. Set up various sexy SVN parts
    cd trunk
    svn propset svn:ignore ‘*’ log
    svn propset svn:ignore ‘*’ tmp/cache
    svn propset svn:ignore ‘*’ tmp/pids
    svn propset svn:ignore ‘*’ tmp/sessions
    svn propset svn:ignore ‘*’ tmp/sockets
    svn commit -m “Set various ignores”
  1. Piston all our dependencies

svn up
piston import http://dev.rubyonrails.org/svn/rails/trunk vendor/rails
svn commit -m “Added Piston’d Edge Rails”

svn up
piston import http://dev.rubyonrails.org/svn/rails/plugins/exception_notification vendor/plugins/exception_notification
svn commit -m “Added Piston’d ExceptionNotification plugin”

  1. Cap baby, cap!
    cap —apply-to .
    svn add config/deploy.rb
    svn add lib/tasks/capistrano.rake
    svn commit -m “Added Capistrano”

svn mv config/database.yml config/database.example.yml
svn propset svn:ignore “database.yml
lighttpd.conf” config
svn commit -m “Moved database.yml and set various config ignores”

  1. Hosted @ segpub.com.au
    rm config/deploy.rb
    curl http://svn.aviditybytes.com/rails/libs/segpub_capistrano_recipe/deploy.rb > config/deploy.rb
    svn commit -m “Changed deployment recipe to the Segpub family recipe”
  1. Topfunky’s hot tip: cache_svn
    curl http://pastie.caboo.se/2973/download > config/cache_svn.rb
    svn add config/cache_svn.rb
    svn commit -m “Added cache_svn.rb from http://pastie.caboo.se/2973”
  1. Database foobar
    cp config/database.example.yml config/database.yml

echo “create database idol_development; create database idol_test;” | mysql5 -u root

./script/generate session_migration
rake db:migrate

echo “* Update your config/environment.rb to use ActiveRecord session store”
echo “* Modify the dispatcher.* shebangs”
echo “* Customise config/deploy.rb”
echo “* Start a codin…”

Bunny

Add salt as required.

Archived comments

Comments were previously allowed on articles. Though no new comments are being accepted you can see the old comments below.

  1. Ben Askins

    Nice article Tim. However, can you clarify why you need to change the dispatcher shebangs?

  2. topfunky

    And I assume it can take a command-line arg to specify the name of the app you’re building?

  3. Don Park

    Awesome article. very helpful for getting things setup in a best-practices way. topfunky: the script starts out like a log of a shell session but ends up like a shell script. i think you’re going to need some $1 vars to take the project name on the command line.

  4. Nathan de Vries

    You might find my SVN cache diff useful. Saves a few headaches.

  5. Fred

    we <3 Tim!

  6. Tim Lucas

    Ben: It’s only if you’re using cgi or fcgi. If the shebang doesn’t point to the ruby interpreter then your dispatcher won’t spawn. In the case of segpub you just change it to use /usr/bin/env ruby (which should also work in your dev environment).

    topfunky: Yeah it’s not a shell script, as it’s not useful to anybody w/o some modification. It’s more of a recipe. I just figured it might be good for people to see how to set things up properly from the beginning. I’m not gonna bother turning it into a shell script for my own use as I don’t use it often enough.

    Nathan: cheers!

  7. Lachie

    cool… I can understand ignoring lighttpd.conf, but why database.yml?

  8. Tim Lucas

    I don’t store database.yml in SVN, instead I just have database.example.yml

  9. Lachie

    Yep, but why not store it? Just curious :)

  10. Steve

    Because if you store database.yml in your svn it A) has your database passwords in it (if that’s an issue—depending on who has access to your repository), and B) will overwrite changes on other systems you may not want it to change (multiple developers working with local dbs for development and testing with different credentials)

  11. Tim Lucas

    What Steve said ;)

  12. Olle Jonsson

    A thought:

    For the curl-fetched script about cache_svn, try this URL:

    http://pastie.caboo.se/2973.txt

    instead of this:

    http://pastie.caboo.se/2973

  13. Olle Jonsson

    Feh, nevermind, the /download is as good as txt. Sorry for not paying better attention.

  14. JoNtE

    I Guess you need to use
    capify .
    instead of “cap —apply-to .” nowdays… right?

    // Jonas Montonen

  15. Philippe Rathe

    Thanks a lot!

Thoughts

toolmantim

I’m Tim Lucas, a user experience developer currently in Sydney Australia.

I occasionally write, snap photos, present on various technical topics, tweet my going-ons, share teh codes and post tidbits to the scrapbook.

Most recently I published Simplifying ticket sales on sydneyoperahouse.com (February 16, 2010)

Work with me via Agency Rainford, or shoot an email to and say hello.

Powered by salt water