"You must provide at least one check", but Rails validation exists

I have the following check:

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 to check?

+6
source share
1 answer

You must call:

 validate :no_multi_day_events 

but not

 validates :no_multi_day_events 
+19
source

Source: https://habr.com/ru/post/975592/


All Articles