ActiveRecord Race Condition
pezra.barelyenough.org
The Rails validations (especially the ensure_uniqueness_of) in my mind are purely for nice error messages 99% of the time. As well as race conditions like you discovered, they are inefficient - if you have a heavily inserted table, then Rails has to select to ensure uniqueness, and then insert - if you just put a unique constrain on the table and do the insert, you save on the select. This would only ever be an issue in a very heavily inserted table that has a unique column, which is probably rare!
-----
I love when something being "probably rare" is justification for it being significantly broken.