Replacing the ‘rails’ command

I always forget about the ‘svn copy’ command, and Josh Susser has reminded me of its awesome usefulness. In this case, its usefulness as a way to start projects.

I took his advice a step further. Rolling on the idea of an ‘Image’ of a basic Rails project with its own repository, on top of setting the svn:ignore properties for log/ and tmp/ I also installed a couple things I use in almost every project:

  1. acts_as_authenticated
  2. ar_fixtures
  3. Capistrano rake and deploy tasks

I also generated an authenticated controller/model and added an initial user to my migration, so I’m all set to login. Before importing my ‘basicauth’ Rails image to subversion, I created my svn best practices directories (branches/ tags/ trunk/) and put the rails code into trunk.

After importing, I’m all set to start as many rails projects as I want. Why not use bash scripting to make it even easier.

echo 'Creating new rails app'
cd ~/Sites/
echo 'Creating repository'
svn copy svn+ssh:// svn+ssh:/$1
echo 'Checking out code'
svn co svn+ssh://$1/trunk $1
cd $1
mate .

If I save this, chmod +x it, and copy it to /usr/local/bin/ – Now all I have to do to start a new rails app is:

myrails anewapp

It will copy the repository, checkout the code, and even open it in TextMate.

2 Responses to “Replacing the ‘rails’ command”

amcvega Says: #

I tried using the code snippet you posted. I get stuck with the svn copy part.

I don’t think svn copy supports cross-repository copying. How were you able to get past it? Are all your projects under one repository?

AQ Says: #

True – For this setup all projects would have to be in one repository. This isnt a problem really if you dont have more then one user (yourself) or a set number of users who have access to everything. I set up a new repository called ‘rails’, and have all my projects underneath it, like
If you want to create seperate repositories for each project, I suppose you could put that in a bash script to, then export the ‘base’ project and reimport it into the new repository.


QuirkeyBlog is Aaron Quint's perspective on the ongoing adventure of Code, Life, Work and the Web.




QuirkeyBlog is proudly powered by WordPress


  • No categories