logandk/mongoid_denormalize — pull request #11 by jbbarth (2012-04-30 16:29:44+00:00)
Title: Patch : use fresh value from database in denormalize_from

It's pretty common in web applications to update the `_id` field directly for updating associations. In this case, mongoid_denormalize doesn't behave like expected because it trusts Mongoid's association cache, which is not reliable, so basically `MyModel#` will fetch the `@` instance variable, which can be out of sync.

So I think mongoid_denormalize should try to hit database when possible (e.g. when the specified field is actually an association, and not a custom method from the model).

Just see the spec for an actual example, it fails without the proposed patch. Let me know what you think.