leah blogs

January 2006

18jan2006 · Getting on a running train

Sometimes I feel so low-down and disgusted
Can’t help but wonder what’s happenin’ to my companions,
Are they lost or are they found, have they counted the cost it’ll take to bring
All their earthly principles they’re gonna have to abandon?
There’s a slow, slow train comin’ up around the bend.
—Bob Dylan, Slow Train

I’ve been doing Rails for three days now (for a project you’ll soon hear of), and, while it was not my first attempt to get started, it certainly was the most successful one.

[Please take the following with a grain of sand, according to rails stats, I already wrote 119 lines of code with Rails. :-)]

The pain kept within reasonable limits, it’s no problem to install Rails without RubyGems by adding an appropriate link for vendor/rails, table pluralization can be disabled easily too (I didn’t do it, though, it’s actually pretty comfortable), mostly, it stays out of my way.

The biggest problem so far is not my lack of understanding something, but not knowing what actually exists. Often, there are useful helpers you just need to know of. Sometimes I wish I had gotten into Rails earlier, so I could have tracked development and wasn’t just run over by it now.

According to Phil Karlton, the two hardest things in Computer Science are naming and cache invalidation. While I didn’t yet touch the latter one with respect to Rails, I certainly hit the former.

Naming the models is comparatively easy, even if some names that I’d really have liked to use are not possible because Ruby already has classes with that name (what do you call a group of posts, if Thread is already taken?); naming controllers is very hard for me, I’m not sure why.

The second biggest problem is fighting with ActiveRecord; in fact, I think all my problems so far can be reduced to wrong use of ActiveRecord. I just hope we will get along better together in the future. (Once you got it to work, it’s pretty nice, of course.) Maybe my database schema was a bit too difficult for a first use. (Featuring self-referential entries etc.)

Finally, an admission: I actually started writing the application five days ago. After fighting with ActiveRecord for a short time, I gave up and wrote an CGI (whopping 483 lines of code). Then, I decided to give it a try again and rewrote it in Rails. That was easy then, of course. The schema just had to be adjusted marginally, the HTML and styling already was done. This may not be the worst idea to get into Rails, provided you have an appropriate application.

So here I am, I think I got on the train, let’s see if I manage to find a seat or get kicked out at the next train station…

[This post was titled “Selling my soul for a train ticket” first, but I decided that would be a bit too negative. ;-)]

NP: Ton Steine Scherben—La Response

Copyright © 2004–2022