Hello. I know the title may be broad, but I am not sure how else to put it.
I am writing a model, in which the attribute "number_of_extensions" needs 2 things:
1. It is required for this model
2. It must be a whole, positive number
I know I can do this simply by
validates :number_of_extensions, presence: true, numericality: { only_integer: true }
However, if I validate for JUST numericality, is it assumed that the attribute SHOULD be present?
In my database, I cannot restrict NULL values for this column. The model I am working on is a child of another, where the main model does not require # of extensions, but this child model does.
Also, while I am talking about validations, I have another question:
I know that the following type of validations is not in the docs anymore, but it is still supported. Would the following line be possible?
validates_numericality_of :number_of_extensions, :number_of_sidecars, :number_of_phones, only_integer: true
Thank you for the time and help!