-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:
Been pulling my hair out on this issue for a couple hours now. I'm not sure what causes it but 2.4.10 introduces a bug where duplicate embedded documents are created on one of my embeds_many relations.
class Post include Mongoid::Document cache embeds_many :topic_mentions, as: :topic_mentionable, :class_name => "TopicMention" def save_topic_mention(topic) existing = topic_mentions.detect{|mention| mention.id == topic.id} unless existing mention = self.topic_mentions.build({name: topic.name}) mention.id = topic.id end end end class TopicMention include Mongoid::Document field :name embedded_in :topic_mentionable, polymorphic: true end
Calling save_topic_mention with just one topic inserts the embedded document just fine. There is only one document on the post when I check in the debugger but after the entire request is complete the resulting database structure has two of the same topic_mention.
2.4.9 works fine, 2.4.10 introduced this problem.
Please let me know if I can provide more information.