How to: ensure file uniqueness. - carrierwaveuploader/carrierwave GitHub Wiki
Add a md5hash field to your model, then put the following code in your model:
before_validation :compute_hash
validates_uniqueness_of :md5hash, :on => :create
def compute_hash
self.md5hash = Digest::MD5.hexdigest(self.data.read)
end