Displaying 1 result from an estimated 1 matches for "second_hurdl".
Did you mean:
  second_hurdle
  
2012 Aug 05
0
ActiveRecord::Validator vs ActiveModel::Validator
...odel:
class RandomlyValidator < ActiveModel::Validator
  def validate(record)
    record.errors[:base] << “FAIL #1” unless first_hurdle(record) #add
error messages to the whole object instead of a particular attribute
using the :base key.
    record.errors[:base] << “Fail #2” unless second_hurdle(record)
    record.errors[:base] << “Fail #3” unless third_hurdle(record)
  end
  private
  def first_hurdle(record)
    rand > 0.3
  end
  def second_hurdle(record)
    rand > 0.6
  end
  def third_hurdle(record)
    rand > 0.9
  end
end
class Report < ActiveRecord::Base...