title: Rails model class method for collection of objects
body: <p>I'm having trouble writing class methods to use on collections of <code>ActiveRecord</code> objects.  I've run into this issue twice in the last couple of hours, and it seems like a simple problem, so I know I'm missing something, but I haven't been able to find answers elsewhere.</p>
  
  <p>Example:</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
  
    belongs_to :customer
  
    scope :month, -&gt; { where('order_date &gt; ?', DateTime.now.beginning_of_month.utc) }
  
    def self.first_order_count
      map(&amp;:first_for_customer?).count(true)
    end
  
    def first_for_customer?
      self == customer.orders.first
      # this self == bit seems awkward, but that's a separate question...
    end
  
  end
  </code></pre>
  
  <p>If I call <code>Order.month.first_order_count</code>, I get
  <code>NoMethodError: undefined method 'map' for #&lt;Class:...</code></p>
  
  <p>As far as I know, that's because <code>map</code> can't be called directly on <code>Order</code>, but needs an <code>Enumerable</code> object instead.  If I call <code>Order.year.map(&amp;:first_for_customer?).count(true)</code>, I get the desired result.</p>
  
  <p>What's the right way to write methods to use on a collection of <code>ActiveRecord</code> objects, but not on the class directly?</p>