{"issue":{"milestone":null,"user":{"login":"alexkwolfe","id":569,"url":"https://api.github.com/users/alexkwolfe","avatar_url":"https://secure.gravatar.com/avatar/72d403ad3c243379dfdb5da3e6179c05?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"72d403ad3c243379dfdb5da3e6179c05"},"title":"embeds_many order cannot be updated","created_at":"2011-02-06T15:47:15Z","labels":[{"name":"bug","url":"https://api.github.com/repos/mongoid/mongoid/labels/bug","color":"e10c02"}],"updated_at":"2011-12-18T14:37:47Z","state":"closed","id":578667,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/mongoid/mongoid/issues/664","closed_at":"2011-12-18T14:37:47Z","body":"I believe embeds_many should allow reordering of the array of embedded docs. This is not working in rc.7. Note that I'm talking specifically about updating the order of the docs, and then saving the parent, as opposed to changing the order of embedded docs at query time.\n\nFailing test case:\n\n      require 'test/unit'\n      require 'mongoid'\n\n      class Parent \n        include Mongoid::Document \n        embeds_many :children \n      end \n\n      class Child \n        include Mongoid::Document \n        field :name \n        embedded_in :parent, :inverse_of => :children \n      end\n\n      class EmbedsManyReorderingTest < Test::Unit::TestCase\n\n        def setup\n          Mongoid.configure do |config|\n            config.from_hash('database' => 'embeds_many_reordering_test')\n          end\n    \n          @parent = Parent.new :children => [ \n            {:name => 'child 1'}, \n            {:name => 'child 2'} \n          ]\n        end\n  \n        def test_should_update_child_order\n          @parent.save!\n          @parent.reload\n          assert_equal ['child 1', 'child 2'], @parent.children.collect(&:name)\n          @parent.children.reverse!\n          @parent.save!\n          @parent.reload\n          assert_equal ['child 2', 'child 1'], @parent.children.collect(&:name)\n        end\n      end","number":664,"url":"https://api.github.com/repos/mongoid/mongoid/issues/664","comments":3,"assignee":null},"comment":{"user":{"login":"durran","id":9030,"url":"https://api.github.com/users/durran","avatar_url":"https://secure.gravatar.com/avatar/6f09262a13427532461b0b618d445b1e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"6f09262a13427532461b0b618d445b1e"},"created_at":"2011-12-18T14:37:47Z","updated_at":"2011-12-18T14:37:47Z","id":3194970,"body":"Resetting the relation with a new order will update it.\r\n\r\n```ruby\r\nmodel.children = model.children.sort\r\n```","url":"https://api.github.com/repos/mongoid/mongoid/issues/comments/3194970"},"action":"created"}