[Ruby on Rails] How to Not Check nil with validates numericality
In Ruby on Rails, to not check nil cases with validates numericality, specify allow_nil: true.
class Article < ActiveRecord::Base
validates :page_view, numericality: true, allow_nil: true
end
Without specifying allow_nil: true, even empty input will result in a validation error saying “xxx must be a number.”
・[Reference]:validation - custom error message for valid numericality of in rails - Stack Overflow
That’s all from the Gemba.