25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/can_has_validations/validators/ordering_validator.rb', line 25
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|
lesser = attr_name.call(record) if attr_name.respond_to?(:call)
lesser ||= record.send attr_name
next unless value && lesser
unless value > lesser
attr2 = record.class.human_attribute_name attr_name
record.errors.add(attribute, :after, options.except(:after).merge!(:attribute2=>attr2))
end
end
end
|