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

Unnecessary requests for accepts_nested_attributes_for

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

      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.

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

              Created:
              Updated:
              Resolved: