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 still 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With