This is old content! The catacombs are a snapshot of content created from 2005-2007. For new stuff, visit Maniacal Rage.

maniacal rage

Garrett Murray lives here. He's the senior developer at Blue Flavor by day and an amateur writer and comedian by night. You can read more about him or
Garrett Murray's hCard
photo

The podcast is finally back with a new episode. We've been on an unplanned hiatus for the past six weeks, but now things are back up and running and we've crammed this episode extra-full of good stuff to make up for our absence. This, I think, is the best episode yet.

If you're not subscribed, you're missing out. Head over to the podcast site and download the latest episode or subscribe.


Here's how I create a new Rails app and start version control using SVN. I keep my repositories in a directory called source and I develop in a directory called rails (under the default sites folder), both in my home directory. For the purposes of this tutorial, I will be creating a new Rails project for development of this site.

This all assumes you've got Ruby, LightTPD (not required), SVN and Ruby on Rails installed. Need to install Ruby/Rails? Check out Dan Benjamin's tutorial over at Hivelogic. It's excellent. Need to install SVN? Check out Dan Benjamin's other tutorial over at Hivelogic, or you can use one of Martin Ott's pre-built packages. This also assumes you're using OS X. Most of this would apply to other platforms, but you'll have to tweak it on your own.

Of course, please be careful, et cetera, no guarantees, you know the drill with all of this. I'm just posting it here so other people can benefit from it, but I can't promise it will work for you (as always, be careful).

  1. Create an SVN repository.

    svnadmin create ~/source/maniacalrage.net
    
  2. Create a basic directory structure for the repository. I use the recommended three top level directores: branches, tags and trunk. I work out of trunk and create branches when I have stable builds. Create this structure in a temporary directory (created below) and then import it into the new repository.

    mkdir ~/temp
    mkdir ~/temp/branches
    mkdir ~/temp/tags
    mkdir ~/temp/trunk
    
  3. Do the initial import of this structure. Note that the location of the repository must be explicitly stated—you can't use ~/. Of course, all ~/ means is /users/your_user_name. Once you're done, you can trash that temporary directory you created (be careful with that rm command!).

    svn import ~/temp file:///users/garrett/source/maniacalrage.net -m "initial import"
    rm -r ~/temp
    
  4. Let's check out your local working copy. There are a couple of things to note about the checkout line—once again, you must specify the full path to your repository (and this time, include the trunk directory since that's where you'll be working from), and you need to give the checkout command the name of the folder you want your working copy to exist in. The most logical choice here is maniacalrage.net.

    cd ~/sites/rails
    svn checkout file:///users/garrett/source/maniacalrage.net/trunk maniacalrage.net
    
  5. Okay, it's time to create your Rails app. You're going to create it inside the directory you just created when checking out. Rails will simply add files to the existing directory.

    rails maniacalrage.net
    
  6. Now that we've got our Rails app in place, we need to add everything it just created to SVN. We're going to force SVN to accept all the files and directories.

    cd maniacalrage.net
    svn add . --force
    
  7. Check those files in.

    svn ci -m "initial rails import"
    svn up
    
  8. We don't want our log files versioned, so let's remove them from SVN and tell SVN to ignore them in the future. You could also ignore the database.yml file, but I never do since I always mimic my development environment's settings when I work from various machines (i.e. I use the same MySQL login and password from machine to machine).

    svn remove log/*
    svn propset svn:ignore "*.*" log/
    svn ci -m "removing log files and ignoring them in the future"
    svn up
    
  9. (If you're going to use Webrick as your local testing server, skip these last two steps—they only apply to LightTPD.) Run your Rails app for the first time and then shut it down (using control-c on the keyboard). This will create the config/lighttpd.conf file.

    ./script/server
    
  10. Add the new conf file to your repository.

    svn add config/lighttpd.conf
    svn ci -m "added lighttpd conf file"
    svn up
    

And you're done. This may seem like a lot of work, but it's actually rather trivial once you've done it once or twice. From this point on, you can begin developing your Rails app and you're all set up for version control. Where do you go from here? A few places:

  • The SVN Guided Tour.
  • SvnX is an open GUI client for Subversion and OS X. Will make several things easier on you in the long run, especially diff viewing with its bundled FileMerge integration. It's also free.

In addition to the following tutorial, you might benefit from the following points of advice:

  1. Open config/lighttpd.conf and change server.port from 3000 to 80. This will allow you to access your site from localhost rather than localhost:3000. This requires you run your local testing server a bit differently, however. First, you need to disable the built-in Apache instance running on OS X, since it runs on port 80.

    /System/Library/StartupItems/Apache/Apache stop
    

    And then you need to launch your server as such and enter your password when prompted:

    sudo ./script/server
    
  2. Add a virtual host to your hosts file to simplify development. For instance, since I'll be developing this site, I'd rather access dev.maniacalrage.net on my local box than localhost. Assuming you have TextMate installed (of course you do!) and the shell command enabled (No? Just visit "Terminal Usage..." in the Help menu in TextMate), open your hosts file for editing:

    mate /etc/hosts
    

    And then add a line after the first localhost line:

    127.0.0.1  dev.maniacalrage.net
    

    Save, enter your password when prompted, and close. Now you can view your new URL when developing and you'll get your Rails app.

Now get to work building your new Rails application, send me lots of gold, and subscribe to the podcast!


Speaking of hosts, I got a few emails from readers who asked me why, after expelling so much praise for Segpub, I would host the podcast and short films at Dreamhost. The answer is actually pretty simple: Dreamhost offers a shitload of bandwidth and disk space, and I don't care about support when I'm basically just hosting files.

Here's what I mean: Segpub offers impeccable service and quality, and beyond fair pricing for their services. What this means is that they don't oversell on bandwidth and disk space like other, "cheap" hosting providers. At Segpub I get more than enough space and bandwidth (and it's gone up significantly as Segpub has built business and expanded), and I pay a fair price for it. But that price isn't less than ten dollars a month, which is what most people are looking for. I know you've heard it a million times, but it's true: you get what you pay for. And Segpub really delivers.

But then there's Dreamhost. Where I pay less than sixteen bucks a month and have over sixty-seven gigabytes of disk space and nearly two terabytes of bandwidth a month. Do you understand how ridiculous that is? There's no way in hell Dreamhost has that much space to give to every customer. They oversell like crazy, and, chances are, I'll never come anywhere near those numbers anyway. But they're cheap and the space is plentiful, and that's all I care about for the podcast and films.

Now, if I had to run a large web app, I wouldn't choose Dreamhost. Their support is slow and hard to come by, and their control panel—while full-featured—is extremely slow and clunky. But, for fifteen bucks a month, I'm hosting over ten domains there with tons of files, our films, the podcast, et cetera, with space and bandwidth to spare. Of course, it goes down every now and then and dealing with Rails apps is a nightmare, but it works well enough for my purposes.

So there you have it: If you need good, fast, quality hosting and excellent support, choose Segpub. If you don't care and you just need server space, choose someone like Dreamhost. But don't say I didn't warn you.


This site is hosted by Segment Publishing and has been for just over two years. Segpub is a fantastic hosting company with unparalleled support and, quite frankly, the fastest Ruby on Rails hosting on the planet. If you're on Dreamhost or TextDrive right now, you have no idea how fast Rails can be when hosted properly—I urge you to look into Segpub if you're looking to host Rails sites, especially larger, mission-critical applications. I get no compensation for anything I'm saying here, or for referrals. I'm just being honest.

I've spent the last five weeks developing a rather large events management site using Rails, and we launched a week ago with Segpub and the results have been nothing less than perfect. Insanely fast application speeds and great support to work out the kinks (all of which I created).

The more I work with Rails, the more I fall in love with it. The past five weeks have been a ton of work, but it's actually been, well, fun, which is not something most people can say about building a large web app. As the popularity of Rails increases, Segpub is going to prove invaluable to people who need their app to work quickly and pain-free. I'm telling you—start now.

And speaking of that five weeks: A majority of my non-work time was been spent sitting around and sleeping, trying to build energy, so everything else suffered. The podcast took an unexpected hiatus, but is coming back this week, and I haven't uploaded any of the photos I've taken over the past several weeks. I'm mostly playing catch-up at this point, but I'm getting there.


Katia: "I just saw on the New York Sports Club website that there's an outdoor, roof-top pool you can join on 34th and 2nd, and then I called to find out how much [it is] for the summer. Guess?"

Me: "One billion dollars."

Katia: "No, guess seriously."

Me: "That was serious."