Ruby on Rails

July, 2017

"In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg."
Bjarne Stroustrup
I hate rails.

I have endured more needless misery and suffering with rails than with any other piece of software I have ever had anything to do with. Consider yourself warned. I intend to migrate completely away from it (and mostly have).

Ruby on Rails (aka "Rails") is a way to develop websites. I first came to rails after a couple of years of being an enthusiastic Ruby programmer. I also had just finished a significant web project using PHP and MySQL. During that project I realized that I was writing the same sort of code over and over and over. I immediately recognized how much rails could have done for me. Given how much I enjoy ruby, I was thrilled at the prospect of doing web development using ruby.

Ultimately though, rails has been a total train wreck, a bitter disappointment, and a source of misery.
Consider yourself warned.

If you are heading down this road, you might also take a look at Sinatra, which is a more lightweight approach to developing websites using ruby. Also, you should keep your eyes on Nodejs(from Google) which is event-driven server-side javascript, now being used to develop dynamic websites.

Learning Rails

My top recommendation at this time is the "Rails Tutorial" by Michael Hartl. You can buy the book or do the tutorial online (as I did). What I strongly recommend though is that you ignore and skip all the TDD (test driven development) stuff on the first pass and just learn rails. You will thank me for this advice! If you like the look of TDD, go back and do the tutorial again and focus on that the second time through.

You also should consider two books. One is the Agile Web Development with Rails book. This should be "the book", but it is not as good as it should be, and does not seem to be getting better. The other is The Rails Way, which I am finding I like better the more I dig into it.

Rails and me

Rails came onto the scene in 2004. I have been fiddling around with rails since sometime in 2005 and started with Rails 1.0.5 or something like that. I own a first edition copy of the Agile Rails book, which got me started. A "legend" in rails history is the "create a blog website in 15 minutes" video. Here it is on you-tube.

My experience with rails has not worked out as nicely as I might have liked or hoped. I have been badly bitten several times by rails projects, and would have been miserable if I had based an important production project on rails. The usual scenario is that when I update the machine that runs my webserver, a new rails update gets installed and breaks rails for me when I least want or expect it. In a nutshell: the rails deployment infrastructure is brittle. Here is the latest example (December 21, 2012).

Another angle on it is that I don't do rails full time. I don't live and breathe rails. I don't spend all my spare time reading rails forums and blogs and I don't want to. My rails projects are just a few of the many things that I do. I get them going, then go off and do other things, then have to come back and fix them when some new wind blows through the rails world.

Here it is 2011, and I am going through another round of this insanity. First there was lighttpd and fastcgi, then it was apache and mongrel and mongrel clusters. Now rails 3 doesn't want to work with mongrel, and something called passenger is recommended. The word is that the rails team thinks unicorn is the answer .... for now. Also there is talk about using the nginx web server instead of apache ... groan! Some of these changes may be for the best, but they sure can be painful.

I now have several years of experience with rails and a couple of small rails based web projects behind me. My words of wisdom to the rails newcomer, given this background, are as follows. Carefully analyze your project and decide if rails is the best tool. As someone has said, rails has its "sweet spot", and if your project is in that zone, you may win big with rails. On the other hand, there is a substantial learning curve. Rails has been called "opinionated software", and if you don't go with the rails flow, it will fight you every step of the way.

I got a big laugh out of this quote in Michael Hartl's excellent rails tutorial. Somewhere in chapter 8, I read:

"much of the elegance of Rails ultimately derives from the malleability of the underlying Ruby language."

I don't want to rag on Mr. Hartl specificaly, but the irony of this in the midst of the rails philosophy of "opinionated software", "syntactic vinegar", and the overall philosophy of "Our way or the highway" is most assuredly not lost on me. It borders on crass hypocrisy. Above all, I believe that rails has limited itself by this vulgar point of view.

Last but not least, rails deployment is a big issue that gets swept under the rug in much of the rails hype. Setting up a web server to handle rails is a nasty and prickly business. Things look great when your project is running on port 3000 of localhost, but there are lots of ugly surprises waiting when you decide to go live.

Since rails is opinionated, I can be too; hence these pages. They are by and large, my own notes for myself, but if they are helpful to you, that is great!

More of my comments on rails (with some frustrated ranting)

Online resources

There is a forum on google groups that discusses rails issues and where questions are asked, and sometimes even answered. Send mail to rubyonrails-talk@googlegroups.com.
This works for me at any rate, but you almost certainly need to join google groups before it will work for you.

Documentation

To get the current documentation for whatever rails version you are running, in some shell window type gem server
Then use this link: Ruby Gems Documentation

Online, you can use: Rails API

My essays

I'll warn you. Many of these document the ugly underbelly of rails and were written during or after periods of bitter frustration with some rails issue. In reverse cronological order:

Books

The first book on rails that was printed is/was the "rails book" Agile Web Development with Rails by Dave Thomas and David Heinemeier Hansson. There are now some better options (see below) in many respects, but this is still "the rails book", for better or worse.
I have the first edition, the second edition came out sometime in 2007, a third edition covers Rails 2, and a fourth edition is forthcoming (as of mid-2010) that will cover Rails 3 and Ruby 1.9

The book is really lacking, and while they are busy telling you how great rails is and how they know the only right way to do things, they drop the ball in a lot of ways. One thing it could use is a systematic API interface (use the web), like the pickaxe book has for ruby itself.

Since I got started with rails (back in 2005?), rails has become wildly popular, and there are lots of rails books now, the trick is sorting out those that are truly valuable from the duds.


Feedback? Questions? Drop me a line!

Ruby on Rails notes / tom@mmto.org