Tag Archives: validation

Drilling Down into Validation Failure

Rails provides model-level validation, which is easy and DRY. But if you have a class that validates multiple fields, how can you verify if validation is failing on the right fields? ActiveRecord provides a convenient errors method with an invalid? method you can call; it takes a field name. Continue reading

Posted in Testing | Tagged , , | 1 Comment

Validation 101

Data validation is crucial to web applications–especially e-commerce applications, where money is involved. Bad data can destroy the usefulness of (or even shut down) an application! What’s more, validation needs to be centralized–you want to keep your validation in one … Continue reading

Posted in Development | Tagged , , , , | 1 Comment

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