Michael Buffington

Weird Ruby on Rails Issue

Wednesday, June 08 2005

Update: I wrote a guide on troubleshooting this issue related to the dreaded “Rails application failed to start” for issues far more routine than the obvious bug I describe below.

I was chugging right along making sweet Ruby on Rails code when I hit a weird snag. I had a column in my database table simply named y, data type of int. The standard Rails scaffolding would show me an empty list when there was no data in the table and allow me to create a new record, but the second I tried to display the record back, I’d get a “Rails application failed to start properly.”

It took me a while to figure this out – first I made sure that the code was working as expected by launching the rails console and creating an object based on my model, adding data to the object, then saving it. Worked fine. Then I retrieved the same data and displayed it. Worked fine. I hit the controller directly from the command line, and saw there were no syntax errors in the Rails generated code.

Because all of my other tables, models, and controllers seemed to be working fine, I began tweaking the offending table. On a whim, I removed the ‘y’ column and everything worked flawlessly. Adding it back produced the same error.

So it seems there’s something with how Active Record interacts with the controller that’s causing tables with columns named ‘y’ to barf.