Reputation: 214
When I add errors in object and save it. I lost those errors which I added. Ex :
@student.errors.add(:base,"error added " )
@student.save
@student.errors.size ---> 0
Please eneyone can say why this is happening?
Upvotes: 0
Views: 604
Reputation: 1098
Why do you need to save the object after adding the error? The errors
are either added through model validations or we add them through some custom logic. The object is not saved in both cases. If you save the object, you would lose the errors.
Upvotes: 1