Tag Archives: debugging

Conditional Code

You’re writing some code for a new client. Debug statements litter the code. Oops, you sent that to the client. Oops, you’re printing out credit-card numbers. Identity theft ensues. Don’t move to Mexico–you can actually handle this problem in an elegant way by using conditional code statements INSIDE your class … Continue reading

Posted in Development | Tagged , , | Comments Off

Missing Attribute: foo

Have you ever gotten the cryptic message Missing Attribute: foo in your code? Rails looks for this attribute in your model, and in the database. It might be that you’re trying to access an attribute that you didn’t select! What’s the solution? Use find_by_sql to add that attribute into your find call. Continue reading

Posted in Development | Tagged , | 1 Comment

Undefined Method Foo

Sometimes, you add an attribute to a class, but when you try and access it, it tells you that the method is undefined. What’s going on? In this article, we discuss a bit about how Rails searches for things (database and code). The answer is probably that you forgot the getters and setters for that attribute! Continue reading

Posted in Development | Tagged , , , , | Comments Off

When New Fails

Sometimes, you say @foo = Foo.new(…) and then @foo.save. But it doesn’t save! In fact, creating the new instance failed! What’s going on? One possibility is that @foo is nil (so it wasn’t created properly). Another possibility is that @foo.id is nil–which means @foo failed validation! Continue reading

Posted in Development | Tagged , , , , | Comments Off