I have the following validation in my model:
validates :cep, presence: true, :unless => lambda { |o| o.location }
How can I customize the error message that shows when the validation fails?
将message
选项传递给validates
方法。
validates :cep, presence: { message: 'Your custom error message' }, unless: lambda { |o| o.location }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.