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

Optimize << when the argument is an array

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

      Given we have a many-to-many relation between Article and Image
      When I do
      article << [image1, image2, image3]
      save should only be called once on the article,
      and once on each image (totaling to 4 calls to #save), as opposed to:
      article << image1
      article << image2
      article << image3
      where #save would be called on both sides 3 times (totaling to 6 calls to #save)
      Currently both behave the same, which isn't optimal.

      I also think this is an issue when you use accepts_nested_attributes_for, so keep an eye out for that as well.

            Assignee:
            Unassigned Unassigned
            Reporter:
            phaza Peter Haza
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: