Checking out Ruby on Rails

My team at work is struggling a bit with getting a website up and running (the technology more so that the design) and I remembered today someone telling me about Ruby on Rails. Being as ADD as I am, of course I dropped everything and started to do a little digging around. I soon found out that the Rails framework, running on the Ruby language, is probably the most productive Web framework out there, comparing very favorably against J2EE and .Net. Rails implements a full-stack web framework incorporating a modern Model2 MVC architecture, similar to Struts, and seems to have built into it just about everything a die-hard Web developer might want: separate development, test and production environments, built-in testing framework, automatic stubs (scaffolding), database bindings, etc.

So far, learning about Ruby and Rails has been full of pleasant surprises. It seems that Ruby is a very modern, interpreted, truly object-oriented language with a natural syntax (to this Java programmer, anyway) and lots of nice built-in operators (actually syntactic sugar for methods, everything in Ruby is an object). I found a cool little tutorial site for Ruby (the language) that lets you type in commands right into an interpreter on the web page: Try Ruby! Its pretty basic, but it is virtually painless and leads you through a number of language basics — I might even have my kids try it.

I decided to run down to the bookstore and purchase a small book: Ruby on Rails: Up and Running (I like small books, they tend to be better written, and are easy to take on an airplane) which walks you through the process of creating websites. It does so in a direct and succinct manner. I’m just starting to work through this book now, but so far, the framework looks very interesting and powerful.

However, before you can really get started cranking out websites, you do need to set up Ruby, Rails and a slew of other dependencies. Depending on your platform, this could get complex. For developers on Mac OS X, there is a tutorial for installing all the important bits that you need to get started: Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X.

There are easier ways to get all the parts installed and running on OS X, one of these being a package installer called MacPorts. However, the easiest and coolest way to get everything needed to start shucking Ruby on Rails (again on Mac OS X) is an open-source project called Locomotive. With Locomotive, you simply drag a folder to install, start the application, and create a new Ruby on Rails application. Everything you need is included in the packaged bundle; Locomotive sets up an environment for you including all the programs, packages, environment variables, etc. all set and ready to go. To get a bare Ruby/Rails skeleton app up and running was simply a matter of clicking ‘Create New’, giving it a name, clicking the Start button, and then browsing to localhost:3000. From there you can open up a terminal window (with the environment all set up for you), or start editing configuration files in your favorite text editor. Very sweet!

More links: