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

Defining a method named "metadata" breaks mongoid

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

      The following method definition in your model:

      Unable to find source-code formatter for language: def. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       metadata
      ...
      end
      

      will result in this error when trying to set the field to a Hash object:

          undefined method `path' for {}:Hash
      (eval):2:in `method_missing'
      (eval):2:in `method_missing'
      .../gems/mongoid-2.3.4/lib/mongoid/atomic.rb:210:in `atomic_paths'
      .../gems/mongoid-2.3.4/lib/mongoid/atomic.rb:148:in `atomic_selector'
      .../gems/mongoid-2.3.4/lib/mongoid/persistence/operations.rb:117:in `selector'
      

      For example, with this code:

      Unable to find source-code formatter for language: doc. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       = Document.first
      doc.metadata = {:one => 1} # or doc.update_attribute...
      doc.save
      

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

              Created:
              Updated:
              Resolved: