开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜