Rails: Custom validation message

后端 未结 1 1695
醉酒成梦
醉酒成梦 2020-12-09 17:52

I\'m trying to make a simple custom validation message. The validation I\'m using compiles and runs fine, but I don\'t see any change in the message:

validates

相关标签:
1条回答
  • 2020-12-09 18:03

    Alright, I solved it. This is the validation that works:

    validates :rating, :inclusion => { :in => 0..5, :message => " should be between 0 to 5" }
    validates :rating, :presence => { :message => " cannot be blank" }
    

    and I added this

    validates :rating, :numericality => { :message => " should be a number" }

    0 讨论(0)
提交回复
热议问题