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

Unnecessary requests for accepts_nested_attributes_for

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.1.0
    • Component/s: None
    • Labels:
      None

      Description

      My airport model has

      accepts_nested_attributes_for :city, :country

      Then I do:

      >> foo = Airport.first
      MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=places selector={"$query"=>{"deleted_at"=>nil, "_type"=>{"$in"=>["Airport"]}}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (41.4884ms)
      #<Airport _id: 4eda60208792904be4002443 ... >

      >> foo.save
      foo.save
      MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=places selector={"$query"=>{"deleted_at"=>nil, "_id"=>"4eda5f2c8792904be40000fc", "_type"=>{"$in"=>["Country"]}}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (1.5063ms)
      MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=places selector={"$query"=>{"deleted_at"=>nil, "_id"=>"4eda5f2e8792904be40001b3", "_type"=>{"$in"=>["City"]}}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.7651ms)
      true

      So it gets every relation listed in accepts_nested_attributes_for despite the fact, that I didn't change anything in the object. These requests look like unnecessary.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            exoth Yuriy Trofimenko
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: