title: Strange Rails ActiveRecord Behavior
body: <p>Can someone please explain why the following queries return diff results?</p>
  <p>If I run a simple &quot;last&quot; query I get an object back.</p>
  <pre><code>    &gt;&gt; j = Job.last
     (1.6ms)  SELECT sqlite_version(*)
     Job Load (0.7ms)  SELECT &quot;jobs&quot;.* FROM &quot;jobs&quot; ORDER BY &quot;jobs&quot;.&quot;id&quot; DESC LIMIT ?  [[&quot;LIMIT&quot;, 1]]
     =&gt; #&lt;Job id: 12, customer_id: 3, description: nil, shoot_start_date: &quot;2020-11-25 
  00:00:00&quot;, shoot_end_date: &quot;2020-11-26 00:00:00&quot;, submission_deadline: &quot;2020-11-27 
  00:00:00&quot;, delivery_deadline: &quot;2020-11-28 00:00:00&quot;, created_at: &quot;2020-11-25 21:44:22&quot;, 
  updated_at: &quot;2020-12-14 19:30:06&quot;, token: &quot;fd2356c1-996b-4f95-b24a-8c92829af1fe&quot;, name: 
  &quot;teesting&quot;&gt;
  </code></pre>
  <p>And with this object I can get children as follows:</p>
  <pre><code>&gt;&gt; j.job_entries
  JobEntry Load (0.7ms)  SELECT &quot;job_entries&quot;.* FROM &quot;job_entries&quot; WHERE 
  &quot;job_entries&quot;.&quot;job_id&quot; = ? LIMIT ?  [[&quot;job_id&quot;, 12], [&quot;LIMIT&quot;, 11]]
  =&gt; #&lt;ActiveRecord::Associations::CollectionProxy [#&lt;JobEntry id: 8, entity_id: 12, 
  agency_id: 35, created_at: &quot;2020-12-07 21:27:47&quot;, updated_at: &quot;2020-12-07 21:27:47&quot;, job_id: 
  12, job_role_id: 8&gt;, #&lt;JobEntry id: 9, entity_id: 13, agency_id: 35, created_at: &quot;2020-12-14 
  17:35:30&quot;, updated_at: &quot;2020-12-14 17:35:30&quot;, job_id: 12, job_role_id: 7&gt;]&gt;
  </code></pre>
  <p><strong>HOWEVER</strong>, when I run a method on my object which is the following code:</p>
  <pre><code>  def self.getJobAndSubmissions(token)
      Job.includes(job_entries: :images_attachments).where(:token =&gt; token)
    end
  </code></pre>
  <p>I get the very same record with attachments:</p>
  <pre><code>&gt;&gt; j = Job.getJobAndSubmissions('fd2356c1-996b-4f95-b24a-8c92829af1fe')
  Job Load (0.9ms)  SELECT &quot;jobs&quot;.* FROM &quot;jobs&quot; WHERE &quot;jobs&quot;.&quot;token&quot; = ? LIMIT ?  [[&quot;token&quot;, 
  &quot;fd2356c1-996b-4f95-b24a-8c92829af1fe&quot;], [&quot;LIMIT&quot;, 11]]
  JobEntry Load (0.2ms)  SELECT &quot;job_entries&quot;.* FROM &quot;job_entries&quot; WHERE 
  &quot;job_entries&quot;.&quot;job_id&quot; = ?  [[&quot;job_id&quot;, 12]]
  ActiveStorage::Attachment Load (1.0ms)  SELECT &quot;active_storage_attachments&quot;.* FROM 
  &quot;active_storage_attachments&quot; WHERE &quot;active_storage_attachments&quot;.&quot;record_type&quot; = ? AND 
  &quot;active_storage_attachments&quot;.&quot;name&quot; = ? AND &quot;active_storage_attachments&quot;.&quot;record_id&quot; IN (?, 
  ?)  [[&quot;record_type&quot;, &quot;JobEntry&quot;], [&quot;name&quot;, &quot;images&quot;], [&quot;record_id&quot;, 8], [&quot;record_id&quot;, 9]]
  =&gt; #&lt;ActiveRecord::Relation [#&lt;Job id: 12, customer_id: 3, description: nil, 
  shoot_start_date: &quot;2020-11-25 00:00:00&quot;, shoot_end_date: &quot;2020-11-26 00:00:00&quot;, 
  submission_deadline: &quot;2020-11-27 00:00:00&quot;, delivery_deadline: &quot;2020-11-28 00:00:00&quot;, 
  created_at: &quot;2020-11-25 21:44:22&quot;, updated_at: &quot;2020-12-14 19:30:06&quot;, token: &quot;fd2356c1-996b- 
  4f95-b24a-8c92829af1fe&quot;, name: &quot;teesting&quot;&gt;]&gt;
  </code></pre>
  <p>But suddenly, child references no longer work.</p>
  <pre><code>&gt;&gt; j.job_entries
  Traceback (most recent call last):
      1: from (irb):4
  Job Load (0.2ms)  SELECT &quot;jobs&quot;.* FROM &quot;jobs&quot; WHERE &quot;jobs&quot;.&quot;token&quot; = ? LIMIT ?  [[&quot;token&quot;, 
  &quot;fd2356c1-996b-4f95-b24a-8c92829af1fe&quot;], [&quot;LIMIT&quot;, 11]]
  JobEntry Load (0.1ms)  SELECT &quot;job_entries&quot;.* FROM &quot;job_entries&quot; WHERE 
  &quot;job_entries&quot;.&quot;job_id&quot; = ?  [[&quot;job_id&quot;, 12]]
  ActiveStorage::Attachment Load (0.2ms)  SELECT &quot;active_storage_attachments&quot;.* FROM 
  &quot;active_storage_attachments&quot; WHERE &quot;active_storage_attachments&quot;.&quot;record_type&quot; = ? AND 
  &quot;active_storage_attachments&quot;.&quot;name&quot; = ? AND &quot;active_storage_attachments&quot;.&quot;record_id&quot; IN (?, 
  ?)  [[&quot;record_type&quot;, &quot;JobEntry&quot;], [&quot;name&quot;, &quot;images&quot;], [&quot;record_id&quot;, 8], [&quot;record_id&quot;, 9]]
  
  NoMethodError (undefined method `job_entries' for #. 
  &lt;Job::ActiveRecord_Relation:0x00005562db1258c0&gt;)
  Did you mean?  entries
  </code></pre>
  <p>What the?  Please help me understand why this is happening!</p>