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

NoMethodError: undefined method `errors' for nil:NilClass on create!

    • Type: Icon: Task Task
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None

      Using Mongoid 3.1.4

      Receive "NoMethodError: undefined method `errors' for nil:NilClass" when calling Model.create!(attributes)

      It's coming from line 277 in persistence.rb:

        fail_validate!(doc) unless doc.insert.errors.empty?
      

      So presumably doc.insert is nil. How could that be possible? Seems like a mongoid bug.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            jeremyhaile jeremyhaile
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: