Tuesday, October 28, 2008

One reason a Rails application breaks with no error message

I'm new to Ruby and Rails and spent about 3 hours trying to figure out why objects of my Purchase model which references my Transaction model weren't being presisted. Rails would say that the object was saved in the database but there were no records being created. Also Rails wouldn't throw any error message either.

After pulling hair for 3 hours I nailed it down to my Transaction model. Apparently Transaction is a reserved keyword in Rails. So once I renamed my Transaction model to Receipt things worked like a breeze.

Here is the list of keywords that will save me from going bald the next time:

Now, I wonder why Rails doesn't detect the use of a reserved keyword and throw an explicit error instead of not only failing silently but also telling me that things are huky-dory!!?