title: Rails custom model method in where query
body: <p>In my rails app I have defined in the <code>Kid</code> model a calculation based on the fields from the <code>Kids</code> DB. the method is as follows:</p>
  
  <pre><code>def flip_date 
    self.dob.advance(months: 10) 
  end
  </code></pre>
  
  <p>I want to use this in my controller as I have a method where I am defining something as follows:</p>
  
  <pre><code>new_kids = Kid.where(discharge_date: nil).where('flip_date &gt; ?', Date.current.advance(year: 1).beginning_of_year)
  </code></pre>
  
  <p>However I keep getting the following error:</p>
  
  <pre><code>SQLite3::SQLException: no such column: flip_date: SELECT "kids".* FROM "kids" WHERE "kids"."discharge_date" IS NULL AND (flip_date &lt; '2017-01-01')
  </code></pre>
  
  <p>Any ideas on how can I make this work? All help is appreciated!</p>