Buduję swoją pierwszą aplikację z mongoidem i mam problem z usunięciem osadzonego zasobu. Mam te modele:usuwanie dokumentów wbudowanych z mongoidem
class Article
include Mongoid::Document
field :body
embeds_many :comments
etc ..
class Comment
include Mongoid::Document
field :body
embedded_in :article, :inverse_of => :comments
end
Nie rozumiem, dlaczego nie mogę usunąć komentarz z artykułu
ruby-1.9.2-p290 :043 > @article.comments
=> [#<Comment _id: 4eb0e991a27d201ded000038, _type: nil, body: "foo", score: nil>]
ruby-1.9.2-p290 :045 > @article.comments.first.destroy
=> true
ruby-1.9.2-p290 :046 > @article.comments
=> []
ruby-1.9.2-p290 :047 > @article.save
=> true
ruby-1.9.2-p290 :049 > @article.reload
=> #<Article _id: 4eb0e991a27d201ded000037, _type: nil, body: "foo", title: ....
ruby-1.9.2-p290 :050 > @article.comments
=> [#<Comment _id: 4eb0e991a27d201ded000038, _type: nil, body: "foo", score: nil>]
Wywołanie zniszczyć (lub usunąć) na Wbudowany dokument wydaje się usuwać go w pamięci, ale nie z bazy danych. Każdy wgląd byłby bardzo doceniany!
cześć. Czy znalazłeś odpowiedź na to pytanie? Naprawdę doceniam każdą pomoc – Ben
Przepraszam - nie - to było jakiś czas temu i nie realizowałem projektu – chrispanda