-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
If you call becomes on a document it'll remove it's associations
For example
class Recipe include Mongoid::Document field :title, type: String embeds_many :ingredients end class RemoteRecipe < Recipe field :source_url, type: String end class Ingredient include Mongoid::Document field :name, type: String field :quantity, type: String embedded_in :recipe end
Now assume the following about recipe.
recipe.title => "Chocolate Crackle Cookies" recipe.class => RemoteRecipe recipe.ingredients => [#<Ingredient _id: 50494933aa113e7f6000001c, _type: nil, name: "Zucchini", quantity: "4 qts.">]
if I then call recipe = recipe.becomes(Recipe) and now recipe is as follows
recipe.title
=> "Chocolate Crackle Cookies"
recipe.class
=> Recipe
recipe.ingredients
=> []