我有以下验证:
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
但是,当我尝试使用此文本加载页面时,出现错误:You need to supply at least one validation
如何提供验证?
答案 0 :(得分:19)
你应该打电话:
validate :no_multi_day_events
而不是
validates :no_multi_day_events