I am trying to use validates_timeliness to ensure that SliderImage.start is always before SliderImage.stop:
class SliderImage < ActiveRecord::Base
validates_datetime :start, :stop
validates :start, :timeliness => {:before => stop}
end
But of course stop is not defined yet. How can I accomplish this?
The stop value must be called on the record object being evaluated. The shorthand version is pass the symbol :stop, and this be assumed to be method on the record which will called at validation time.
Otherwise you can use a lambda like so
I would tend to write your validation as
p.s. I’m the plugin author 🙂