[Rails] Custom Validations

Nick Stuart
Sun, 02 Apr 2006 02:04:49 -0000

Another way to do ''custom'' validation is to simply supply a
"validate"
method in your class. This gets called before you save/update. You can
simplify a bit what Ian has suggested.

#just place this in your model class
def validate
  errors.add_to_base "A or B are required" if a.blank? and b.blank?
end

Hope this helps!
-Nick