Things to like about Rake and Rails.
Posted by nito, Wed Mar 07 02:10:00 UTC 2007
I get a phone call at 8:30am, it's an agency - calling from germany, about a contract they think I might be interested in.
"Can we point the client to a site of yours?"
"Sure." I say, "myrailsite.net is a good site to show them."
Two hours later i get an email from the agency.
Subject: Website Error
Is there any other Homepage which the client could have a look at? Because the website myrailsite.net says:
Application error
Change this error message for exceptions thrown outside of an action
(like in Dispatcher setups or broken Ruby code) in public/500.html
I'm scratching my head.
An application error. Why? It was working only two weeks ago. Granted, It's a site i've been neglecting a little, but shouldn't that neglect pretty much guarantee it remaining in a state of fossilisation?
If I don't change anything, It should all be fine, shouldn't it?
No.
myrailsite.net is hosted on one of dreamhost's servers. A shared server.
After steeling myself with a robust cup of coffee and a chocolate bourbon (the biscuit, not some chocolatised alcoholic beverage), I embarked upon a little digging, googling and peering through production logs, where the predominant error appeared to concern deprecated things (you'll have to bear with me here - I was under pressure and I wasn't taking notes! and it's late now, and really, those 'things' that were deprecated aren't that important. No really. Believe me).
A smatter of chattering to #ruby and #rubyonrails people confirmed my worst fears:
Dreamhost had upgraded their version of rails to 1.2 since I had last looked at myrailsite.net. The upgrade broke my application because of my application's reliance on Engines and specifically, the now very deprecated LoginEngine. Dammit. Drat. Expletive deleted.
So at this point I'm feeling a little embarassed that a site I'm demonstrating isn't up and running, but also a little relieved that the problem isn't actually my fault. 'So', I thought, 'no worrys, I'll make a copy of the app, mess with it, fix it, give it a quick test and all will be fine'...
Of course, I'm trying to do this in a hurry because I want the client to see a working site. And because I'm trying to do it in a hurry it's just not going to happen is it. And even if i was trying to do it properly, it's never going to happen quickly because it would really require pulling out the LoginEngine and replacing it with something like restful authorization or some such, and doing it properly And I'm just hacking, so it's not going to work for me, is it. And, of course, it doesn't. I try a few things, including some migrations etc, but eventually I give up on that route.
At this point, the coffee and the biscuit are beginning to kick in and I go hitch a ride on the clue-train. I suddenly tune into a little voice in the back of my mind that says again and again: 'Change the version back to 1.1.6'. Of course. How silly. Now I feel stupid. Why didn't I just do that to begin with? Probably because I'm only human and it was a stressful day, and, as usual, I wasn't listening to myself and I wasn't being very zen. The fix takes no longer than the time it takes to type one line into the shell:
[milliken] rake rails:freeze:edge TAG=rel_1-1-6
Voila, we have a working website again. Of course we also have a little something to write about, a bit of rake/ruby/rails to glow about.
What we learnt today: When we're deploying our applications in the wild, onto hosted services like textdrive or Dreamhost, or myfavouritehoster, take control of our rails applications and avoid at least -some- embarassing hiccups by freezing to an edge.
if it makes you nervous, you can always unfreeze!

