title: Rails nested includes and belongs_to vs. has_one
body: <p>I am writing an application for a job board. There is a <code>Users</code> table where users can post jobs or request to be awarded jobs. Therefore my <code>Jobs</code> table has a user_id field for the posting user and a relationship to a <code>Job_requests</code> table that has a job_id and a user_id but here the user_id is the requesting user's id. </p>
  
  <p>I am trying to show a job posted by a user:</p>
  
  <pre><code>current_user.jobs.find(params[:id])
  </code></pre>
  
  <p>including the requests for that job:</p>
  
  <pre><code>current_user.jobs.includes(:job_requests).find(params[:id])
  </code></pre>
  
  <p>but also including the details for the requesting user:</p>
  
  <pre><code>current_user.jobs.includes(job_requests: :user).find(params[:id])
  </code></pre>
  
  <p>The first two work but the third crashes with the following error:</p>
  
  <pre><code>SQLException (no such column: users.job_request_id)
  </code></pre>
  
  <p>I know there is no such column I am looking for the details of the user that posted the request. </p>
  
  <p><strong>Model Association</strong></p>
  
  <pre><code>User
  has_many :jobs, dependent: :destroy
  has_many :job_requests
  
  Job
  belongs_to :user
  has_many :job_requests
  
  JobRequest
  has_one :user
  has_one :job
  </code></pre>