Is there a way to clear out the data of all embedded documents.
For example I have a contact with:
- Email Addresses
- Phone Numbers
- Addresses
I have new data for all these fields and I want to replace them all. This is being done via a gem so it must me dynamic. I cant just call each embedded model and run destroy_all.
What is the best way to delete all the data from embedded documents?
There is no better way. You must call destroy_all on every reference you want to clear. This is a domain specific requirement and not very common.