title: rails, deleting record if exists with a same column value before creating a new record
body: <p>i have an object person which has a "has_many" relationship with photo object</p>
  
  <pre><code>has_many :photos, :foreign_key =&gt; 'person_id', :dependent =&gt; :destroy
  </code></pre>
  
  <p>and on photo:</p>
  
  <pre><code>belongs_to :person, :foreign_key =&gt; 'person_id'
  </code></pre>
  
  <p>what i want to do. is during an update of person, if a user uploaded a new photo to that person with the same "kind" (which is an attribute of photo) so the old kind be deleted from the db</p>
  
  <p>for example: 
  an update is being performed on person with an uploaded photo with kind "face" 
  if a record of photo already exists with the same 'person_id' and the same "kind"
  it will first be deleted (not updated) and only the then the new record be saved</p>
  
  <p>thanks</p>