i’m begining with the gem mongoid in rails3 .
I want to know how i can increment manually a field containing an integer.
I’ve tried a lot of method but no one work well.
And i’d like to know if this action can be done in an atomic context ?
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.
For Mongoid versions previous to 4
from the mongoid docs, assuming that a Person model has an Integer field of ‘score’, this would increment the score by 100:
more info: http://mongoid.org/en/mongoid/docs/persistence.html#atomic