title: How to validate uniqueness in Rails 3 Model if I want to check if there is a 2-field combination?
body: <p>I want to know if there is a way in Rails 3, in which I can validate the uniqueness of 2 fields that goes in combination.</p>
  
  <p>The logic goes this way:</p>
  
  <p>I have two fields <code>employee_code</code> and <code>date_entry</code>.</p>
  
  <ul>
  <li><p>Case 1: If the <code>employee_code</code> and <code>date_entry</code> combination already exist it won't allow to save another record with the same <code>employee_code</code> and <code>date_entry</code>.</p></li>
  <li><p>Case 2: If the <code>employee_code</code> and <code>date_entry</code> exists but not on the same record, it will allow to save the field.</p></li>
  </ul>