how would I validate that one field of my Model is "smaller" compared to another?
class Event < ActiveRecord::Base
validates :start, :presence => true
validates :stop, :presence => true
end
In addition - how could I make sure that the "difference" between the two values doesn't exceed a maximum range?
Cheers
I have a validation that's similar to this to make sure school years begin before they end and are not longer than a year.
So you could do something like this.
So, just picking an example range of 30 days:
I strongly recommend the validates_timeliness gem for these sorts of date validations. It makes it much simpler and more reliable to check for these sorts of things, and in a way that's also more readable so someone else can quickly grok the intent of the validation.