Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"You need to supply at least one validation" but Rails validation exists

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?

like image 315
Eric Baldwin Avatar asked Sep 20 '14 22:09

Eric Baldwin


1 Answers

You should be calling:

validate :no_multi_day_events

and not

validates :no_multi_day_events
like image 127
Marcelo Ribeiro Avatar answered Sep 26 '22 06:09

Marcelo Ribeiro