Monday, May 8, 2006

AJAX and mod_ruby

I decided to take advantage of the fact that my colleague's computer was down to rewrite the question database that I maintain for my students. Since it was going to be work moving it to my home machine anyway, I may as well enable ajax on it, right?

The process went smoothly for the most part. One snag was that the server often choked on an include file. Once every 7 or 8 loads it would complain that a method was not found.

It turns out that the problem was the way apache and mod_ruby cache ruby code. The require command apparently doesn't cache the code for each of the running subprocesses for apache. When you hit one of the non-cached ones, you get trouble. The solution is to replace "require" with "load".

Thanks to Tim Bates for posting a message about how to fix it. His post is here.

No comments: