I am reading the rails guides. I am trying create a class Validator but I get the following error message in console
uninitialized constant Product::GoodnessValidator
model product.rb
class Product < ActiveRecord::Base
validates_with GoodnessValidator
end
class GoodnessValidator < ActiveModel::Validator
def validate(record)
if record.amount == 12
record.errors[:base] << "The amount musn't be 12"
end
end
end
Aucun commentaire:
Enregistrer un commentaire