1

I have this validation in my model:

validates_uniqueness_of :micro_id, :conditions => ["date_active not null and date_inactive null"]

I interpret this as: okay to insert if this is the only record where the micro_id is 2695 AND date_active is not null AND date_inactive is null.

In the database, for micro_id 2695, I have one record: It has a date_active and a date_inactive. I should be able to insert a new record for 2695 when I have a date_active and a null date_inactive. But, I cannot insert a record. I've determined this is the validation that is causing the validation error.

Am I interpreting this validation incorrectly?

Thanks,

4

1 に答える 1