Rails snippet: require app files only once

Ruby’s Kernel.require method will re-require the same source file if you pass it differing arguments that point to the same file. It doesn’t use File.expand_path to make sure it hasn’t already loaded the same file before. This can cause problems if you’re using constants or doing one-time initialization in a source file that’s getting loaded multiple times for one reason; you’ll need to add a wrapper that prevents re-entry.

If this annoys you as much as it does me (why should my application code include workarounds for what I regard to be a Ruby bug?), add this snippet to your config/environment.rb (pre Rails 2.0) or config/preinitializer.rb (Rails 2.0 or later).
Continue reading “Rails snippet: require app files only once”

Why mod_rails is great for light-duty Rails apps

The Ruby on Rails story is usually presented to the new developer as a wonderful break from tradition that makes a developer’s life so much better than the frameworks of the past. The clattering of skeletons in the closet you’re hearing? Well, that’s because it makes the sysadmin’s life much worse than PHP or Java. That just improved on Friday, with the release of mod_rails. If you’re looking for a way to do shared (or low traffic) hosting of Rails applications, this is for you.
Continue reading “Why mod_rails is great for light-duty Rails apps”

Leopard Upgrade Report: Mo’ Features, Mo’ Problems

(Apologies to The Notorious B.I.G. for the title.)

I upgraded to Mac OS X 10.5 “Leopard” recently. In short, it’s not ready for mainstream use. There are a few nice improvements, but these are balanced by numerous problems that make me wish I had waited until, say, June 2008 or so. If you haven’t upgraded and aren’t sure that you need to, I suggest that you wait a few months, until some of the bugs have been worked out.
Continue reading “Leopard Upgrade Report: Mo’ Features, Mo’ Problems”

Capacity vs. Scalability

In I still don’t get the fascination with Ruby on Rails, Andy Davidson writes:
Scaling does not mean “Allows you to throw money at the problem”, it means “Can deal with workload”. He goes on to recommend mod_perl instead of Rails.

I’m not interested whether he likes Rails or not. Lots of people hate Rails, and I don’t care. I’m not going to make a big deal about the fact that he’s comparing a runtime architecture (Apache + mod_perl) with a framework (Ruby on Rails).

Those are insignificant compared to his claim that scalability means “Can deal with workload”. Actually, that’s a description of capacity.
Continue reading “Capacity vs. Scalability”