Я создаю свое первое приложение с помощью mongoid, и у меня возникают проблемы при удалении встроенного ресурса.У меня есть эти модели:
class Article
include Mongoid::Document
field :body
embeds_many :comments
и т. Д.
class Comment
include Mongoid::Document
field :body
embedded_in :article, :inverse_of => :comments
end
Я не понимаю, почему не могу удалить комментарий к статье
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>]
Вызовуничтожить (или удалить) во встроенном документе, кажется, чтобы удалить его в памяти, но не из БД.Любое понимание будет очень ценится!