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

Possible regression from 2.3.4 regarding initialization of Hash fields

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

      Given this document:

      class Article
        include Mongoid::Document
      
        field :details, type: Hash
      
        def foo=(f)
          self.details[:foo] = f
        end
      end
      

      In 2.3.4 the code snippet below works with no problem, as :details is initialized with {}:

      a = Article.new
      a.foo = "foo"
      

      However in 2.4.0 it no longer works, as self.details is nil after initialization.

            Assignee:
            Unassigned Unassigned
            Reporter:
            behrangsa behrangsa
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: