If you look at all the different validations and all their different
options, there is some overlap. I think it’s good overlap… i.e. when
a particular validation makes sense to have X,Y and Z as options, it
shouldn’t matter if another validation already has Y. Others may
disagree, but I like the idea that, for example,
validates_numericality_of has the right options for all the
numericality validations I’d need.
Of course, it could get too convoluted and the argument for using
multiple validations for a single attribute has value as well.
So I can see both sides of it, although I lean more toward the
“overlap is ok” side. (Oh no! The DRY police are banging on my door!)
And based on that, I’d say: add a :not_equal_to to
validates_numericality_of and then maybe also add a generic
But only if you are going to release it. If you just need it to solve
your particular issue, then adding a :not_equal_to is the best and
quickest solution, IMO. You’ll already have the numeric validation and
you can get the not equal to 0 as a parameter on the validation
instead of a separate validation call.
If you’d rather not write any custom code, then I suspect that:
validates_exclusion_of :number, :in => 
should do what you need, right?
Just some ramblings.
On Apr 4, 6:43 am, Phillip K. [email protected]