I have the following validation:
class Event < ActiveRecord::Base
attr_accessible :starts, :ends
validates :no_multi_day_events
private
def no_multi_day_events
if (ends.day != starts.day)
errors.add(:ends, "No multi-day events")
end
end
end
However, when I try to load a page with this text, I get an error: You need to supply at least one validation
How do I supply the validation?
You should be calling:
validate :no_multi_day_events
and not
validates :no_multi_day_events
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With