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

add_to_set requires field to be defined

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Not sure if this is meant to be a breaking backwards change, but while upgrading to Mongoid 4 I can no longer use code that uses dynamic fields.

      class User
        include Mongoid::Document
      end
      
      User.first.add_to_set(dynamic_field: 'foo') # => raises error
      

      The error is caused by this line existing = send(field) || (attributes[field] ||= []).

      Are atomic dynamic fields meant to no longer be supported?

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

              Created:
              Updated:
              Resolved: