I have a Rails 5 app with a Relations table. The table columns looks like:

fromable (polymorphic)
toable (polymorphic)

I want to prevent users from saving relations that are duplicates (that is, that have the same fromable and toable). I've tried to do the following:

```
class Relation < ApplicationRecord

   ...

   belongs_to :fromable, polymorphic: true
   belongs_to :toable, polymorphic: true

   validate :is_not_duplicate_relation

   private

   def is_not_duplicate_relation
      errors.add(:base, "DUPLICATE") if Relation.where(toable: self.toable).where(fromable: self.fromable)
   end
end

```

But this seems to trigger invalid on everything?