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

HABTM :inverse_of => nil broken in 2.3.2

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

      class Movie
       include Mongoid::Document
       has_and_belongs_to_many :ratings, :inverse_of => nil
      end
      
      class Rating
       include Mongoid::Document
      end
      
      Movie.new :ratings => [Rating.new]
      => TypeError: keys must be strings or symbols
      

      Mongoid is correctly determining there is no inverse foreign key field (so is nil), but still tries to do the update to the Rating anyway (i.e. tries to do something like

      Unable to find source-code formatter for language: update. 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
      (nil => movie._id)

      , hence the

      Unable to find source-code formatter for language: typeerror. 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
      
      

      .

            Assignee:
            Unassigned Unassigned
            Reporter:
            bensymonds Ben Symonds
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: