I have the following validation. I am using the new sintaxis of Ruby on Rails, where can be declared many validations to a same attribute, but I need a custom error message for each validation
validates :user_name, presence: true, uniqueness: true
for example validates_presence_of :user_name, message: "Can not be empty"
validates_uniqueness_of :user_name, message: "Must to be unique"
有关示例,请参阅文档:
validates :user_name, uniqueness: { message: "Must to be unique" }
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.