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

Strange behaviour of #count over Mongoid::Relations::Targets::Enumerable

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I don´t know if it is the intended behaviour but it feels a little weird to me

      class Driver
      has_and_belong_to_many :cars
      end

      class Car
      has_and_belong_to_many :drivers
      end

      > car=Car.new
      > car.drivers<< Driver.new
      > c.drivers.one?
      => true # Ok
      > c.drivers.count
      => 0 # ¿?¿?¿?

      I think that if the method #one? tells me that there is one member, the method #count should tell me the same...

            Assignee:
            Unassigned Unassigned
            Reporter:
            ghost Deleted user
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: