Is there a way to save a MongoMapper model instance such that validations are not performed but callbacks are called? This would be analagous to ActiveRecord's whatever.save(false)
I found a snippet of code online that can be used to bypasses both validations and callbacks:
doc = whatever.to_mongo
Whatever.collection.save(doc, :safe => true)
So if there is an easy way to also manually run callbacks, I could use that along with the above snippet above to do it. But that would s开发者_运维技巧till be an inelegant and verbose way to do something relatively simple -- I'm hoping there is a simple way build into the API to skip just validations.
Found the answer:
whatever.save :validate => false
精彩评论