global

def raises_uniqueness_violation?(&block)

This method should be used if you don't care about the exception itself.
whether a uniqueness violation is raised by the block and return the exception if so.
In cases where retrying on uniqueness violations cannot work, this will detect
def raises_uniqueness_violation?(&block)
  transaction(:savepoint=>:only, &block)
  false
rescue unique_constraint_violation_class => e
  e
end