title: Model has a attribute based on a query (N+1)
body: <p>I have the next model. It has an attribute base on a query. Because that attribute I have the N+1 problem when I show the record on my application.</p>
  
  <p>Doing <code>Dish.all.includes(:entries)</code> will not work because this section <code>from_today.from_current_time</code> of the query.</p>
  
  <pre><code>class Dish &lt; ApplicationRecord
    has_many :entries, dependent: :destroy
  
    belongs_to :user
    belongs_to :category
  
    before_validation :init, on: :create
  
    def available?
     current_entry = entries.from_today.from_current_time
     return false if current_entry.count.zero?
     current_entry.first.dishes_left.positive?
    end
  
  end
  </code></pre>