Is there any one command in Mongoid to delete an object using id?
Something like,
ClassName.delete(:id)
Currently i dont see anything like that and im using,
obj = ClassName.find(:id)
obj.delete
Can it be any better?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do something like the following:
You need the underscore in
_idor it won’t work.Also, it may not matter, but
destroy_allwill run the model’s callback methods whiledelete_alldoes not.