Suppose we have a simple model that stores two integers: min and max. We would like to force min <= max.
class MinMax
include MongoMapper::Document
key :min, Integer
key :max, Integer
validate_presence_of :min, :max
end
1) How would you confirm that min is really equal to or less than max?
2) If you do not think that this is the responsibility of the model, then where and who should do this check?
source
share