Do not specify options[:message] for ActiveModel::Errors#add if it's nil

This commit is contained in:
Greg Sterndale 2010-12-28 15:24:59 -05:00
parent 8d9637249c
commit 731338ed6c

View file

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