Riding the Rails

The first couple of times I didn’t really know what they were talking about, I’d seen the name before, but usually just as the title of a forum or blog post that I didn’t bother to read. Once I realized that they were talking about a web development framework, I felt like I knew where the loop was, but still couldn’t understand why so many people had so much to say about it.

I’m talking, of course, about Ruby on Rails, and all the extra work my tired desktop developer’s brain had to do to filter out all the Rails evangelism. Well, the time came; I had enough free time to give it a try, and I wanted to know what all the fuss was about.

Before we start, let’s be generous and call my web development experience "limited", "scarce" might be more appropriate, but it sounds a bit mean.

Getting Started

A sensible first step to get started with Ruby on Rails might be to go to the download pages and download the package for installation on a testing server or PC. Not for me, in the past when I tinkered with anything web related, I always found it a bit depressing once I realized that anything I created wasn’t going to go any further than my laptop. I needed to find some affordable Rails-capable hosting.

After a short search, I decided to go with Dreamhost, their generous affiliate program resulted in a great deal of about $30 for a year’s hosting. It’s a good package too; unlimited domains, 5GB storage and 120GB bandwidth, and MySql and Rails support. It was only after purchase that I found out about the 30-40 minutes of CPU time per day limitation which I assume would rule out hosting a real rails application under the plan, but it’s still a great option for testing and development. And, about that affiliates program, as an affiliate you get a $97 referral bonus towards your next hosting bill, but you can choose to give away all or most of it as a discount to the new users you refer (use my code "gavinsentme", to save up to $90).

So, did it work?

Well, no, it didn’t.... There are some tutorials on dreamhost’s knowledge base, and a useful wiki page, but it still took me a while to get up and running. After I got all the hosting set up, I realised I was going to have to use a shell on the server to run the Rails setup scripts. I downloaded a free terminal program called PuTTY so I could log in, then realised I needed an ftp account on the server which allowed shell access. By this time, when I managed to log in and run the rails command, I was a little surprised when all of the relevant files and directories which support the framework were created.

I tried the homepage, I got the "You’ve put Ruby on Rails" congratulations page, things were looking good. Then I ran through a list of suggestions from the wiki page which involved things like chmod’ing, changing paths in some handler files, downloading and installing updated versions of other files and enabling Fast CGI. I was a bit out of my depth here, so perhaps it was no surprise that when I eventually sat down and tried to access my first Rails controller, nothing happened. I got long delays and generic 500 error pages. I thought maybe I should have created a database first, so I created my database and updated the database.yml config file. Still nothing.

I searched the forums and the web, finding some suggestions that I needed to use dos2unix, and some suggestions that I probably hadn’t chmod’d properly. I could explain how I thought that probably wasn’t it and tell you some of the other things I tried while I kept looking, but as that’s what I eventually did, I’ll cut the story there. Using my shell connection, I ran the dos2unix command on the files I’d changed or replaced, and I ran all the suggested chmod commands again, and suddenly it worked, perfectly. I could finally get started on those tutorials.

I think my mistake here was trying to switch the configuration to use Fast CGI right away... I get the impression that if I’d just gone straight from the rails command to the first tutorial, I would have had no problems, just slower responses from the server.

Actually trying Rails

With my server now working, I charged into the todo list tutorial. I didn’t have to go far before I realised why I’ve been hearing so much about Ruby on Rails. I followed through Curt Hibbs’ OnLamp tutorials too, they covered similar ground, but it was so quick, easy and fun that I was quite happy to repeat myself.

I liked how I could have basic database maintenance pages with one line of code. I liked how I didn’t have to change any code if I changed a database table, and I like the way everything is automatically split into model-view-controller.

I hate to jump on the bandwagon, but working with Rails felt great, I felt empowered, like I would be able to work faster and have more fun doing it.

Conclusion

Obviously I’ve only scratched the surface, so you will probably take everything I’ve said with a pinch of salt, but I’m not trying to make you a Rails convert, I’m just suggesting you give it a try. I’m glad I did.

Bandwagons aren't bad!

Its always nice to have company :)

Good review

Thanks for sharing your experience, Gavin. I'm a web developer who hasn't tried Rails, and I've said in the past that I have to target my professional development towards my career, which doesn't include Rails and likely never will. But, that doesn't stop me from being curious, like yourself. I'd be interested in reading more about your initial experiences with Rails if you continue working with it; that way, I can learn vicariously through you!

Sure

That must take a lot of discipline on your part, Rusty, I'm always far more interested in things I'm unlikely to use!