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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 5.1.0
    • Fix Version/s: 6.0.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      Ruby Sprint 33

      Description

      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

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: