I have a rails model that has attributes 'term' and 'section'. I want a uniqueness constraint on these attributes, so I tried this:
validates_uniqueness_of :term, scope: :section
This would only work when both 'term' and 'scope' were not nil, but I want the constraint to still apply when there are nil values. Looking at the ActiveRecord::Validations docs, I saw that setting 'allow_nil' to false would prevent the skipping of validation when an a value is nil. But the default value for this option is already false.
I tried setting allow_nil to both false and true anyways, but there was no change in behavior. Does anyone know why I cannot get the validation to work when there are nil values?
:scopeto:section? - Alirezatermmust be unique for all records that have the same value forsection. - Patrick Oscity