26
Oct
2007
Single Table Inheritance validates_uniqueness_of Problem
Consider a case of STI where:
Now try following at console:
This will let you create three records in users table with same name, validates_uniqueness_of written in User class has no effect on it. validates_uniqueness_of automatically scoped with class names, that means it will not let you create two managers with same name or two customers with same name or two users with same name.
If you want uniqueness of an attribute in overall table, put the following code in some file in your lib dir and require that file in environment:
And then use validates_overall_uniqueness_of instead of validates_uniqueness_of.


Working with Vinsol has been one of the most rewarding and productive collaborations I've ever had in the technology industry. Manik is an intelligent and honest engineer with a great faculty for open and clear communication, and his team include some of the swiftest and keenest developers I've ever had the pleasure to work with. They're great value for money, excellent people who are a joy to know and interact with, and above all they really know their stuff