I am not able find the record using Model.find(id).
Food.find('548210e8d5a81037af06b2d6') => Mongoid::Errors::DocumentNotFound
But when I try find the same record using column name , I will return same record.
Food.where({name:"Aloo Matar" }).first
=> #<Food _id: 548210e8d5a81037af06b2d6, rawOrPrepared: "P", name: "Aloo Matar", tags: "vegetable", alternateNames: "potatoes">
For my case, find works differently based on string. Please see the below code.
Food.where({_id: "zyCMnbTPENeXkhawT" })
=> #<Mongoid::Criteria
selector: {"_id"=>"zyCMnbTPENeXkhawT"}
options: {}
class: Food
embedded: false>
2.2.1 :017 > Food.where({_id: '548210e8d5a81037af06b2d6' })
=> #<Mongoid::Criteria
selector: {"_id"=>BSON::ObjectId('548210e8d5a81037af06b2d6')}
options: {}
class: Food
embedded: false>
But first code returns the object while second code raise the exception.
Please help me on this.
Thanks, Hare