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

`fields` turns out to be an invalid name for a field

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 6.0.0
    • Affects Version/s: 5.1.0
    • Component/s: None
    • None

      I have a model called Block, which embeds {{Field}}s.

      But when I define embeds_many :fields it breaks with a somewhat unclear error:

      irb(main):020:0> Block.new()
      TypeError: no implicit conversion of String into Integer
      	from .../lib/mongoid/relations/proxy.rb:150:in `[]'
      	from .../lib/mongoid/relations/proxy.rb:150:in `method_missing'
      	from .../lib/mongoid/relations/embedded/many.rb:406:in `method_missing'
      	from .../lib/mongoid/fields.rb:102:in `apply_default'
      	from .../lib/mongoid/fields.rb:74:in `block in apply_pre_processed_defaults'
      	from .../lib/mongoid/fields.rb:73:in `each'
      	from .../lib/mongoid/fields.rb:73:in `apply_pre_processed_defaults'
      	from .../lib/mongoid/document.rb:108:in `block in initialize'
      	from .../lib/mongoid/threaded/lifecycle.rb:89:in `_building'
      	from .../lib/mongoid/document.rb:104:in `initialize'
      	from (irb):20:in `new'
      	from (irb):20
      

      So I guess fields should be a member of Mongoid.destructive_fields

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            koen Koen Punt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: