Setting Up An Initial Subversion Repository For Rails
So you’re getting into Ruby on Rails and decide to stay hip by using it with Subversion, but you’re not quite sure how to go about it. What do you do? Read on of course!
I was asking the same question a few days ago setting up my (mt) Media Temple DV 3 server, and besides that process being worse than giving yourself a paper-cut in your eye while trying to keeping them open staring into the sun, I figured it out and thought I’d share. This is very general, so it should apply to most deployment platforms.
Alright, let’s get started!
I’m going to assume a few things here, which are:
- You know very basic Rails
- You know very basic Subversion
- You’re fine working a linux shell
- SVN and Rails are already installed on both the server and your dev box
- You know how to use VIM
Alright great, so ssh on over into your server and let me know when you’re in. Good? Okay great, let’s get our hands dirty.
First, let’s create our repository:
svnadmin create testapp
I really hope I don’t have to explain how this works.
Okay now, let’s go into the conf directory in the actual repository on the file system. On my (mt) dv, it’s located in /usr/local/bin:
cd /usr/local/bin/testapp/conf
Now let’s open up svnserve.conf:
vim svnserve.conf
You’ll want to uncomment the following (press i to enter insert mode to edit):
anon-access = read
auth-access = write
password-db = passwd
realm = My First Repository
When you uncomment these, make sure to get the extra space, so the first column is not a space or a #. Now press ctrl-c and then :wq to save and exit. Now open passwd:
vim passwd
Create your username and pass like the example show. To have no password, just do:
username =
Save and close that sucker, and get outta’ yo serva’. Get into a nice clean empty dir (or one where you have all your rails projects). Let’s create a setup folder and hop into it:
mkdir setup
cd setup
Now let’s make a rails project:
rails testapp
Now the standard is to make a trunk, branches, and tags layout for Subversion, so let’s stay hip:
mv testapp trunk
mkdir branches
mkdir tags
Now if you’re sharing or on a dev team, this is where you would rename your database config file, so everyone can use their own. But since I have no friends that even know what Ruby on Rails is, let alone Subversion, I’m gonna’ skip his. Oh, and because I’m lazy.
So let’s get this sucker into version control:
svn import . svn://yourserverdomain/testapp -m "Initial import"
This sucks all the files in the current directory into your repository. Great, now we have to check this out, back onto our computer. Fortunately that’s easy, so let’s get out of our setup folder and get into the one we just checked out:
cd ..
svn co svn://yourserver/testapp/
cd testapp/trunk
Almost there! But before we finish up, let’s ignore a few things we don’t want, and finally commit it:
svn propset svn:ignore "*" log/
svn propset svn:ignore “*” tmp/
svn commit -m “Ignoring log and tmp”
Whew, all done! Not so bad, was it? You can delete your setup directory now, or copy the database file if you did that on your own. Now when you’re generating the hell out of Rails, you can use -c to auto add those suckers automagically:
script/generate controller person -c
That’s it for now. I’ll be posting my experience and how I got (am getting) the Media Temple DV 3.0 server working with Cap, Rails, and SVN. Enjoy!
October 18th, 2007 at 9:35 am
would you be willing to do this install on my media temple dv site? i’m working with a RoR developer, but he’s having trouble with the install.
let me know!
October 18th, 2007 at 10:48 am
Sure, just get in touch with me via email. andrew at visualcondition dot com