Tim Gittos

I'm an Australian currently living in Austin, TX in the USA.

I currently earn a living programming, though I wouldn't call myself a programmer. If I had to attach a label to myself, I'd use the term autodidact.

I love learning, and my favorite things to learn about are programming, computer graphics, AI & machine learning, robotics, painting and creativity.

Rails 3.1 Model Property Name Gotcha

Last updated on 28 Oct 2011

If you’re trying to instantiate a Rails model and you keep getting nil back instead of an instance of that model, chances are you have done something dumb like try to create a property on that model called “class”, or something equally ill-advised.

I haven’t tested this for all Ruby keywords, but chances are good that if the build in Object class has an instance property by the same name as one of your model properties, you’re going to run into trouble.

It’s obvious when you’re not dealing with the consequences, but when you’re sitting there in a console and your .new instantiation is returning nil, this get pretty confusing.