3Spoken

Rails Subversion TNG – Creating a new application

Creating a New Rails Application with Subversion

Once you have the .subversion/config file in place, then managing Rails apps becomes very simple indeed.

First catch your repository

Before you can start using version control you’ll need a writeable Subversion repository somewhere. If you haven’t one handy you can create a file based one.

mkdir -p $HOME/repos
svnadmin create $HOME/repos/my_app
export MY_REPOS=file://$HOME/repos/my_app

If you want trunk, tags and branches in your repository then the sequence is:

mkdir -p $HOME/repos
svnadmin create $HOME/repos/my_app
export REPOS=file://$HOME/repos/my_app
svn mkdir -m 'Add trunk, tags and branches' $REPOS/trunk $REPOS/tags $REPOS/branches
export MY_REPOS=$REPOS/trunk

Alternatively if you already have a writeable repository somewhere, point a shell variable at it.

export MY_REPOS=<url to your subversion repository>

For example a Rubyforge SVN repository would look something like this:

export MY_REPOS=svn+ssh://fred@rubyforge.org//var/svn/shizzyapp

Create the initial Rails layout

Checkout a blank working copy and add Rails to it.

svn co $REPOS my_app_wd
rails my_app_wd
cd my_app_wd

And now the magic command

To bring the Rails structure under the control of Subversion all you do is:

svn add --force .

That’s it. No commit of a useless version 1, no scripts, no messing around with svn property settings. The config file deals with it all for you.

Add some structure

Before you create that all important version 1 commit you can, if you wish, add some structure to the layout, e.g

script/generate model --svn post title:string created_on:date

The --svn flag tells the generator to create the files on the disk and also to add them automatically to Subversion.

However if you forget (and we’ve all done it), then

svn add --force .

from the base directory of your application will add in the missing files for you.

And commit those changes

Once you are ready, commit the changes to the repository:

svn commit -m 'Initial layout'

But I forgot to create a working directory first…

If you create a rails app in a normal directory, rather than a blank working copy, then you can bring it under version control fairly easily. Create a blank repository and then from the base directory of your Rails application run:

svn co $MY_REPOS .
svn add --force .

and commit if required

svn commit -m 'Initial Layout'

Advertisements

Create a free website or blog at WordPress.com.

%d bloggers like this: