Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2970

Reset counters with subclassing

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.4
    • Affects Version/s: None
    • Component/s: None

      A subscription has many packs. ShippingPack belongs_to a subscription, is counter_cached there. ShippingPacks inherit from Pack.

      [29] pry(main)> Subscription.reset_counters('5169a505196ebff8ad00001d', :packs)
      => [:packs]
      [30] pry(main)> Mongoid::IdentityMap.clear
      => {}
      [31] pry(main)> Subscription.find('5169a505196ebff8ad00001d')[:packs_count]
      => nil
      [43] pry(main)> Subscription.find('5169a505196ebff8ad00001d')[:shipping_packs_count]
      => 3
      

      I would expect packs_count to be three, and shipping_packs_count to be 0. I.e., it should use the named association's name.

      Can write a pull if this makes sense.

            Assignee:
            durran Durran Jordan
            Reporter:
            pehrlich pehrlich
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: