This blog is part of our Rails 5 series.
Active Record validations by default provides an error messages, based on applied attributes.
But some time we need to display a custom error message while validating a record.
We can give custom error message by passing
What’s new in Rails 5 ?
Rails 5 allows passing record to error message generator.
Now we can pass current record object
in a proc as an argument, so that we can write
custom error message based on current object.
Revised example with current record object.