2011-09-07 69 views
0

我有一個創建一個註釋對象,其中一個答案的has_many意見的例行動作。丟失數據mongoid 2.2.0/mongohq

我遇到一個奇怪的錯誤,當一個新的評論發佈到這個問題的答案是偶爾刪除一個答案現有的評論。新的評論被刪除。

MongoHQ好心地指示我這個問題:https://github.com/mongoid/mongoid/issues/1173,但我使用的是mongoid2.2,它應該沒有這個問題。

class Answer 
    include Mongoid::Document 
    has_many :comments, :dependent => :delete 

class Comment 
    include Mongoid::Document 
    belongs_to :answer 

# answer controller 
def comment 
    answer=Answer.find(params[:id]) 
    c=Comment.new(:text=>params[:text],:user_id=>current_user.id,:answer_id=>answer.id) 
    success=c.save 

    respond_to do |format| 
    format.json { 
     render :json=>c.to_json 
     else 
     render :json=>{"failure"=>c.errors}.to_json 
     end 
    } 
    end  
end 

更多細節這裏包括: http://pastie.org/2488895

回答

0

我被降級到2.0.2 mongoid固定它。這似乎是一個非常具體的錯誤,只有在一個1-N的關係發生了,如果你在mongohq。希望它被固定在mongoid> 2.2