Validates_uniqueness_of in update

I have a problem with the usage of validates_uniqueness_of that I
hope someone can help throw a light on. With a new record, this
validation works fine. But my problem came when I am updating a
record. I was not able do it because it tells me that field value
already exists. I was actually updating the value of other fields.

According to the documentation which says “When the record is updated,
the same check is made but disregarding the record itself.” And it
seems like this isn’t happening. Just wondering what is it that I am
not doing correctly. I am using Rails 2.1.0

Thanks in advance for your inputs,

Steve

Found the reason why it wasn’t working in the Update mode. There was
another record with the same field value as the one that I was
updating. I missed that test record previously created. Once I remove
all duplicated records, the validate_uniqueness_of works as expected
in the Update.

Steve

On Sep 3, 7:52 pm, stevel [email protected] wrote:

Found the reason why it wasn’t working in the Update mode. There was
another record with the same field value as the one that I was
updating. I missed that test record previously created. Once I remove
all duplicated records, the validate_uniqueness_of works as expected
in the Update.

Consider putting a unique index on your unique columns in the
database.

Christian