title: Unknown column in 'where clause' Rails 4
body: <p>RoR noob here. I'm working on a RoR project with mysql.
  I get this error when trying to delete a <code>foto</code>(photo) that has 1 or more <code>comentarios</code> (comments) in it. </p>
  
  <blockquote>
    <p>Mysql2::Error: Unknown column 'fotos.foto_id' in 'where clause': DELETE FROM <code>comentarios</code> WHERE <code>comentarios</code>.<code>id</code> = 21</p>
  </blockquote>
  
  <p>When destroying a photo, it looks for any comments that has the same <code>foto_id</code> so it can delete it as well. But the problem is that for some reason, it looks for <code>comentarios.id</code>  instead of <code>comentarios.foto_id</code>.</p>
  
  <p>My <code>foto.rb</code> model has this line:</p>
  
  <pre><code>has_many :comentarios, dependent: :destroy
  </code></pre>
  
  <p>so it should delete any comments that any given photo has.</p>
  
  <p>And my <code>comentario.rb</code> model has this:</p>
  
  <pre><code>belongs_to :foto
  </code></pre>
  
  <p>the <code>fotos#destroy</code> method in the controller looks like this:</p>
  
  <pre><code>def destroy
  @foto.destroy
  respond_to do |format|
    format.html { redirect_to mias_path, notice: 'Foto eliminada correctamente.' }
    format.json { head :no_content }
  end
  </code></pre>
  
  <p>end</p>
  
  <p>As simple as it gets. But i can't manage to find the error.</p>
  
  <p>The project is stored on github, so if you need to check any other piece of code, or want to try it out for yourself, it's there (it even includes the database i use): 
  <a href="https://github.com/NashTG/PHOTOLOGG-2.0/" rel="nofollow">https://github.com/NashTG/PHOTOLOGG-2.0/</a>
  (the error happens when you log in as an admin, go to 'Todas las Fotos' and press 'Eliminar' on any of the photos that has any comments)</p>
  
  <p>Thanks in advance (i really apreciate any fast answers because i'm on the deadline for this project)</p>