Bonjour,
Unable to autoload constant NameValidator, expected /home/arbi/RailsProject/Formation/app/models/validators/name_validator.rb to define it
j'ai cree un dossier validator dans le dossier model et dedans une classe name_validator
class NameValidator < ActiveModel::Validator
def validate(record)
if record.name.nil ? || record.name.length != 2
record.errors.add(:name, :not_2 , {message: "le champ doit etre de 2 car"})
if record.content.nil ? || record.content.length != 2
record.errors.add(:content , "le champ doit etre de 2 car")
end
end
end
dans application.rb
config.autoload_paths << "#{Rails.root}/app/models/validators/"
Unable to autoload constant NameValidator, expected /home/arbi/RailsProject/Formation/app/models/validators/name_validator.rb to define it :(