jjzjj

DocumentNotFound

全部标签

ruby-on-rails - Mongoid::Errors::DocumentNotFound raise_not_found_error

*在底部更新*当寻找不存在的用户时,我得到:Mongoid::Errors::DocumentNotFoundinUsersController#showProblem:Document(s)notfoundforclassUserwithid(s)22.Summary:WhencallingUser.findwithanidorarrayofids,eachparametermustmatchadocumentinthedatabaseorthiserrorwillberaised.Thesearchwasfortheid(s):22...(1total)andthefollowin

ruby-on-rails - 如何处理 Rspec 中的 Mongoid::Errors::DocumentNotFound?

我有一个带有以下代码的ArticleController:defedit@article=current_user.articles.find(params[:id])end以及以下测试:describe"GET'edit'"doit"shouldfailwhensignedinandeditinganotheruserarticle"dosign_in@userget:edit,:id=>@another_user_article.idresponse.should_notbe_successendend但是,当我开始测试时,出现以下错误(这是正常的),但我想知道如何处理才能让我的测

mongodb - 虽然我在数据库中有记录,但它给出的是 "Mongoid::Errors::DocumentNotFound"

虽然我有ID为13163的记录(db.locations.find({_id:13163})),但它给我错误:Mongoid::Errors::DocumentNotFoundinLocationsController#showProblem:Document(s)notfoundforclassLocationwithid(s)13163.Summary:WhencallingLocation.findwithanidorarrayofids,eachparametermustmatchadocumentinthedatabaseorthiserrorwillberaised.The