开发者

unknown validator even though it is in the Rails Guide on validators and callbacks

开发者 https://www.devze.com 2023-03-26 23:23 出处:网络
I am trying to validate that scores are greater than zero in my answer model when an answer is updated. Here is what开发者_Go百科 i have so far.

I am trying to validate that scores are greater than zero in my answer model when an answer is updated. Here is what开发者_Go百科 i have so far.

validates :score, :greater_than => 0, :on => :update

However, i am getting this error:

Unknown validator: 'greater_than'

I found the greater_than validator here. Thanks for your help.


Try this:

validates :score, :numericality => {:greater_than => 0}, :on => :update 
0

精彩评论

暂无评论...
验证码 换一张
取 消