views:

74

answers:

1

Hi

I have a document with an embedded document in it.

I have 2 forms, 1 that updates fields in document and one that updates fields in emdedded docs.

They are split into 2 forms as lots of fields in each etc and actually this is just a simple example of the structure of my app.

Everywhere else that i reference this data it makes most sense to store in one doc and not split them.

Problem is when i save say for 1 using update_attributes just the fields from form 1 get saved, then when i goto form 2 just the fields from for 2 are saved and i lose data saved in form 1.

Is there a way to skip saving an emdedded docuemnt with a callback, so i can say for example if come from form 1 ? dont update embedded doc. And if come from form 2 just save embedded doc ?

Hope this makes sense.

Any one help or advice ? Thanks Rick

A: 

Not sure how it's exposed in MongoMapper, but the MongoDB operation you're looking for is an update with $set to just set the fields you need. So if you drop down to the ruby driver it should be pretty easy to set just the fields you care about.

mdirolf