Unknown validator, even if it is in the Rails Guide on validators and callbacks

I am trying to verify that in my response model, the score is greater than zero when the response is updated. Here is what I still have.

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

However, I get this error:

 Unknown validator: 'greater_than' 

I found a more_than validator here . Thank you for your help.

+6
source share
1 answer

Try the following:

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

Source: https://habr.com/ru/post/894541/


All Articles