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

Mongoid 7.0 create instance with has_many validation issue

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.0.12
    • Component/s: Associations
    • None
    • Environment:
      pro

      To whom it may concern, 

      We have models like this:

      class User
        has_many :clients
      end
      
      class Client
        has_and_belongs_to_many :tasks, counter_cache: true
      end
      

      And the issue is

      user = User.create
      user.clients.create(attributes)
      
      Raising Error:
      TypeError: no implicit conversion of Symbol into Integer
      

      It was from here enumerable .
      Because when creating contact I am not passing any task attributes.  At the same time counter_cache is trying to count tasks which is nil for this case.

      It was working correctly for mongoid 6.4. 

      Your fast reply is very appreciated as we are counting on version 7 to improve our server side performance. Many thanks!

       

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            gracezhangyaofei@gmail.com Grace Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: