Merge branch 'errors_fix' of https://github.com/gsterndale/couchrest_model into errors_fix

This commit is contained in:
Sam Lown 2011-02-02 20:17:51 +01:00
commit 1ccb96bf56
2 changed files with 8 additions and 1 deletions

View file

@ -6,7 +6,9 @@ module CouchRest
def validate_each(document, attribute, value)
values = value.is_a?(Array) ? value : [value]
return if values.collect {|doc| doc.nil? || doc.valid? }.all?
document.errors.add(attribute, :invalid, :default => options[:message], :value => value)
error_options = { :value => value }
error_options[:message] = options[:message] if options[:message]
document.errors.add(attribute, :invalid, error_options)
end
end
end