How to add custom errors to the User errors collection?

前端 未结 4 1337
南方客
南方客 2021-01-31 02:59

How can I add errors to the User model manually?

Is it just @user.errors << \"some text goes here\" ?

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 03:15

    try this:

    errors.add(:base, "#{user.full_name} has errors here!")
    

提交回复
热议问题