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

Mongoid 7.0 create instance with has_many validation issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Gone away
    • 7.0.12
    • None
    • Associations
    • None
    • pro

    Description

      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!

       

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: