title: Callback vs validation
body: <p>I created a callback when creating a new Client object instead of using the <code>validates_uniqueness_of</code> validation method because:</p>
  
  <ul>
  <li>I want to find the Client that already exists</li>
  <li>Add the existing Client details to my base error message</li>
  </ul>
  
  <p>My question: <strong>is there a more elegant way of achieving this than my solution below?</strong></p>
  
  <p>I have the following <strong>model</strong>:</p>
  
  <pre><code>class Client &lt; ActiveRecord::Base
    before_validation_on_create :prevent_duplicate_clients
  
    private
      def prevent_duplicate_clients
        client = self.class.find(:all, :conditions =&gt; ["first_name = ? AND middle_name = ? AND last_name = ? AND date_of_birth = ?", self.first_name, self.middle_name, self.last_name, self.date_of_birth])
  
        if client.size &gt;= 1
          self.errors.add(:base, "Client exists as #{client.first.name}")
          false
        end
      end
  end
  </code></pre>
  
  <p><strong>NB:</strong></p>
  
  <ul>
  <li>Rails v2.3.5</li>
  </ul>