11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/can_has_validations/validators/ordering_validator.rb', line 11
def validate_each(record, attribute, value)
compare_to = Array.wrap(options[:value_of] || options[:values_of] || options[:in] || options[:with])
compare_to.each do |attr_name|
greater = attr_name.call(record) if attr_name.respond_to?(:call)
greater ||= record.send attr_name
next unless value && greater
unless value < greater
attr2 = record.class.human_attribute_name attr_name
record.errors.add(attribute, :before, options.except(:before).merge!(:attribute2=>attr2))
end
end
end
|