module ActiveRecord
  class Base
    def number_of(assoc)
      @number_of ||= {}
      @number_of[assoc.to_sym] ||= send(assoc).size
    end
  end
end

module ActiveRecord
  class Base
    def number_of(assoc)
      @number_of ||= {}
      @number_of[assoc.to_sym] ||= send(assoc).try!(:size) || 0
    end
  end
end

Handle gracefully missing number_of nil
Handle gracefully missing number_of nil

Handle gracefully missing number_of nil, which can occur when
we delegate association and the receiving object is nil.4

Fixes BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1364458
