Friday, November 16, 2007

validates_presence_of: Ironic Little Rails Gotcha

validates_presence_of doesn't validate itself. If for some lunatic reason you're up and writing code at 8:26 AM, and you make a standard brain-lacks-coffee error like asking a model to validate the presence of some attribute it doesn't actually even have, the model will go ahead and validate against that missing attribute - preventing you from saving anything.