I had this on my models:
validates :deal_sector_id,
presence: true,
numericality: { only_integer: true }
deal_sector_id is a integer postgresql column.
I'm starting to doubt that numericality: { only_integer: true } is necessary in my validations, as when I upgraded to shoulda-matchers 3.0, I get this error message :
You are attempting to use validate_numericality_of, but the attribute
you're testing, :deal_sector_id, is an integer column. One of the
things that the numericality matcher does is to assert that setting
:deal_sector_id to a string that doesn't look like an integer will
cause your deal to become invalid. In this case, it's impossible to
make this assertion since :deal_sector_id will typecast any incoming
value to an integer. This means that it's already guaranteed to be
numeric! Since this matcher isn't doing anything, you can remove it
from your model tests, and in fact, you can remove the validation from
your model as it isn't doing anything either.
As you read above, it says "... and in fact, you can remove the validation from your model as it isn't doing anything either."
Should I use numericality: { only_integer: true } on 'integer' database tables' columns?