title: How to query a model with an one-to-one association in Rails
body: <p>I want to find all cards (belong to a user) where <code>next_review</code> is before current time <code>Time.zone.now</code>.</p>
  
  <p>Below is my mode,</p>
  
  <p><a href="https://i.stack.imgur.com/qFOC2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qFOC2.png" alt="enter image description here"></a></p>
  
  <p><strong>Expect Behavior</strong></p>
  
  <p>I should keep my finder method inside the corresponding model,</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :cards
    def next_cards
      cards.next_cards
    end
  end
  
  class Card &lt; ActiveRecord::Base
    has_one :meta
    def next_cards
      # what should I write here?
    end
  end
  
  class Meta &lt; ActiveRecord::Base
    belongs_to :card
    # what should I write here?
  end
  </code></pre>
  
  <p><strong>What I am thinking</strong></p>
  
  <ol>
  <li>query meta table where(next_repetition &lt; today)  inside <code>meta</code> model and get all target meta(s)</li>
  <li>join (1) results to card table, to find the targets cards  inside <code>card</code> model</li>
  <li>return target cards inside <code>user</code> model</li>
  </ol>