I Know Where “– tables()” Comes From!
After four days of hunting through Rails code, my own, Rails proper, and plugins I finally know where the errant “– tables()” is coming from: a plugin I’d completely forgotten about.
In production Apache was throwing back the following error:
Application error
Rails application failed to start properly
In effect a 500 error – something died on the server. The server logs revealed the following:
[Thu Jul 19 14:23:13 2007] [error] [client 70.79.1.4] malformed header from script. Bad header=– tables(): dispatch.cgi
A good googling of that error seemed to indicate that it mainly gets caused in Rails app by developers who leave puts statements in, probably because when Rails is run locally using lighttpd those puts are written out to the console. Very handy for debugging.
However under Apache those puts are written out as part of the HTTP header which causes the server to puke, which then throws a 500 error, which Rails then returns as that nice little inoffensive error message.
So I scoured my code for every instance of puts and p I could find and commented them out (I don’t tend to use them for debugging, that’s what the Logger is for but if you grep your Rails project you’ll see a ton of them laying about).
Nothing changed, that wasn’t it. puts was not the culprit.
Today I noticed that it only happened in the one project of three I’m working on. diff the configuration and environment files for those projects – no tell-tale differences of any importance.
Then today over lunch it occurred to me that the only signifigant difference between Rails projects over which I don’t exercise total control is the plugins I use. And sure enough the three apps all share the same plugins save for one.
Comment out the require statement for that plugin in its init.rb file and voila! Problem goes away.
Four days of wonderment solved with a simple =begin...=end statement.
Developers often get chastised (perhaps mostly behind our backs) for not thinking our code could ever be the problem, it must always be something else. Well, for once it really was something else. Ha.
Now I can get back to fixing all my own bugs.