I think it’d be helpful if you provide us with a little bit of context.
What are you trying to achieve?
Basically, you have two lines of defense: the app and the database. Like
Colin said, if uniqueness is an essential constraint in your domain then
you should enforce it at the database level. You can also use Active
uniquness validator to display a nice error message (but this w/o the
database-level constraint is not enough). If there’s a race condition
Active Record will raise RecordNotUnique.
If you tell us a bit more we might be able to give you more specific