datamapper/dm-validations — pull request #64 by rykov (2013-07-16 09:38:53+00:00)
Title: Fix uniqueness validation to correctly work with STI

Currently, uniqueness validation check is done by calling `resource.model.first`, which only scopes the query to that particular class. This patch uses `property.model` instead to scope the query to the class in which the property was defined and its children.

This is the best solution that I could find. There is no easy way to scope the query to the class which calls `validates_uniqueness_of`, only the class that defines the property.