title: column is there, but I receive: SQLite3::SQLException: no such column: requestor.birthyear
body: <p>I have a meetings table, which has a requestor (user) with an attribute birthyear.</p>
  
  <p>In the terminal I can do Meeting.find(1).requestor.birthyear</p>
  
  <p>But in the meeting controller, it says <code>no such column: requestor.birthyear</code></p>
  
  <p>I tried adding something like <code>users_attributes: [:birthyear]</code> in the meetings_params, but it didn't make any difference.</p>
  
  <p>What am I missing?</p>
  
  <p>Here are the full files:
  meeting controller</p>
  
  <pre><code>def community
    if current_user.birthyear != nil
      @meeting_requests = Meeting.where('meeting_time &gt;= ? AND requestee_id IS ? AND status = ? AND (requestor.birthyear &lt;= ? AND requestor.birthyear &gt;= ?)', Date.today, nil, "Active", current_user.birthyear + 10, current_user.birthyear - 10).order('meeting_time asc')
    end
  end
  </code></pre>
  
  <p>meeting model</p>
  
  <pre><code>class Meeting &lt; ApplicationRecord
      belongs_to :requestor, class_name: "User"
      belongs_to :requestee, class_name: "User"
  end
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>SQLite3::SQLException: no such column: requestor.birthyear: SELECT "meetings".* FROM "meetings" WHERE (meeting_time &gt;= '2017-03-06' AND requestee_id IS NULL AND status = 'Active' AND (requestor.birthyear &lt;= 1944 AND requestor.birthyear &gt;= 1924)) ORDER BY meeting_time asc
  </code></pre>
  
  <p>Let me know if you need anything further - thank in advance!</p>
  
  <p>UPDATE</p>
  
  <p>trying to join the tables in the query, but not too knowledgeable on that. I'm trying:</p>
  
  <pre><code>@meeting_requests = Meeting.where('meeting_time &gt;= ? AND requestee_id IS ? AND status = ? ', Date.today, nil, "Active").order('meeting_time asc').joins("INNER JOIN users on requestor.birthyear &gt;= current_user.birthyear + 10")
  </code></pre>
  
  <p>but get:</p>
  
  <p><code>ActionView::Template::Error (SQLite3::SQLException: ambiguous column name: status: SELECT "meetings".* FROM "meetings" INNER JOIN users on requestor.birthyear &gt;= current_user.birthyear + 10 WHERE (meeting_time &gt;= '2017-03-07' AND requestee_id IS NULL AND status = 'Active' ) ORDER BY meeting_time asc):</code></p>
  
  <hr>
  
  <p>*****UPDATE*****
  I posted another question to get the syntax. If it helps anyone:
  <a href="https://stackoverflow.com/questions/42654118/rails-two-where-queries-each-works-individually-but-not-together">Rails: Two &#39;where&#39; queries - each works individually, but not together</a></p>