{"action":"opened","issue":{"url":"https://api.github.com/repos/mongoid/mongoid/issues/3936","labels_url":"https://api.github.com/repos/mongoid/mongoid/issues/3936/labels{/name}","comments_url":"https://api.github.com/repos/mongoid/mongoid/issues/3936/comments","events_url":"https://api.github.com/repos/mongoid/mongoid/issues/3936/events","html_url":"https://github.com/mongoid/mongoid/issues/3936","id":56241282,"number":3936,"title":"Recursive embedding trouble","user":{"login":"vmamaev","id":1883631,"avatar_url":"https://avatars.githubusercontent.com/u/1883631?v=3","gravatar_id":"","url":"https://api.github.com/users/vmamaev","html_url":"https://github.com/vmamaev","followers_url":"https://api.github.com/users/vmamaev/followers","following_url":"https://api.github.com/users/vmamaev/following{/other_user}","gists_url":"https://api.github.com/users/vmamaev/gists{/gist_id}","starred_url":"https://api.github.com/users/vmamaev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmamaev/subscriptions","organizations_url":"https://api.github.com/users/vmamaev/orgs","repos_url":"https://api.github.com/users/vmamaev/repos","events_url":"https://api.github.com/users/vmamaev/events{/privacy}","received_events_url":"https://api.github.com/users/vmamaev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-02T14:14:14Z","updated_at":"2015-02-02T14:14:14Z","closed_at":null,"body":"Hello, \r\nI have a problem with more than 4-level trees. I try to create 1.1.1.1.1 and 1.1.1.2.1 into 1.1.1.1 and 1.1.1.2, but gem creates both entries into 1.1.1.1.\r\n\r\n**Model** (as documentation http://mongoid.org/en/mongoid/v3/relations.html)\r\n```\r\nclass Tag\r\n  include Mongoid::Document\r\n  recursively_embeds_many\r\n  field :name, type: String\r\nend\r\n```\r\n\r\n**Rails console commands**\r\n```\r\n>> parent = Tag.new(name: '1')\r\n#<Tag _id: 54cf7e29766d613d590e0000, name: \"1\">\r\n\r\n>> parent.save\r\ntrue\r\n\r\n>> child = parent.child_tags.build\r\n#<Tag _id: 54cf7e4d766d613d590f0000, name: nil>\r\n\r\n>> child.name='1.1'\r\n\"1.1\"\r\n\r\n>> child.save\r\ntrue\r\n\r\n>> child = parent.child_tags.first.child_tags.build\r\n#<Tag _id: 54cf7e6b766d613d59100000, name: nil>\r\n\r\n>> child.name='1.1.1'\r\n\"1.1.1\"\r\n\r\n>> child.save\r\ntrue\r\n\r\n>> child = parent.child_tags.first.child_tags.first.child_tags.build\r\n#<Tag _id: 54cf7e83766d613d59110000, name: nil>\r\n\r\n>> child.name = '1.1.1.1'\r\n\"1.1.1.1\"\r\n\r\n>> child.save\r\ntrue\r\n\r\n>> child = parent.child_tags.first.child_tags.first.child_tags.build\r\n#<Tag _id: 54cf7e98766d613d59120000, name: nil>\r\n\r\n>> child.name = '1.1.1.2'\r\n\"1.1.1.2\"\r\n\r\n>> child.save\r\ntrue\r\n\r\n>> child = parent.child_tags.first.child_tags.first.child_tags.first.child_tags.build\r\n#<Tag _id: 54cf7ec9766d613d59130000, name: nil>\r\n\r\n>> child.name='1.1.1.1.1'\r\n\"1.1.1.1.1\"\r\n\r\n>> child.save\r\ntrue\r\n\r\n>> child = parent.child_tags.first.child_tags.first.child_tags.last.child_tags.build\r\n#<Tag _id: 54cf7eea766d613d59140000, name: nil>\r\n\r\n>> child.name='1.1.1.2.1'\r\n\"1.1.1.2.1\"\r\n\r\n>> child.save\r\ntrue\r\n```\r\n\r\n**Result**\r\n![rec_emb_many_trouble](https://cloud.githubusercontent.com/assets/1883631/6001822/cc45f536-aafe-11e4-9ced-85daa8b0f217.png)\r\n\r\n\r\n\r\n"}}