Created
September 21, 2012 06:53
-
-
Save hanshasselberg/3760076 to your computer and use it in GitHub Desktop.
sample mongoid exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> Product.find("123") | |
Mongoid::Errors::DocumentNotFound: | |
Problem: | |
Document(s) not found for class Product with id(s) 123. | |
Summary: | |
When calling Product.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 123 ... (1 total) and the following ids were not found: 123. | |
Resolution: | |
Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples. | |
irb(main):002:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment