lib/ripple/validations/associated_validator.rb in ripple-0.9.2 vs lib/ripple/validations/associated_validator.rb in ripple-0.9.3
- old
+ new
@@ -22,7 +22,13 @@
def validate_each(record, attribute, value)
return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all?
record.errors.add(attribute, :invalid, options.merge(:value => value))
end
end
+
+ module ClassMethods
+ def validates_associated(*attr_names)
+ validates_with AssociatedValidator, _merge_attributes(attr_names)
+ end
+ end
end
end