Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add custom errors to the User errors collection?

How can I add errors to the User model manually?

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

like image 600
Blankman Avatar asked Mar 16 '11 04:03

Blankman


People also ask

How do you implement a custom error page?

Steps for Custom Error PageCreate a separate folder for Error. Add Web Form for custom error page. Set <customErrors> setting in Web. Config file of the application.


1 Answers

 @user.errors.add(:email, "Not valid") 

If you don't want to use any attributes, then in your model

 @user.errors[:base] << "This person is invalid because ..." 

For details: link

like image 127
Ashish Avatar answered Sep 17 '22 15:09

Ashish