marshaling ActiveRecord objects: how to unload associations?

I'm marshaling ActiveRecord objects, and I want them to be as small as possible. How can I unload everything that can be reloaded from the database?

If they're marshaled before any of the associations are referenced then the referenced objects aren't dumped. But if the association has been loaded, how can I unload it? AssociationProxy.reset doesn't seem to do it. It seems that after the AssociationProxy has been touched at all then dumping the object causes the AssociationProxy to load everything.

Thanks!

Paul Dowman wrote:

I'm marshaling ActiveRecord objects, and I want them to be as small as possible. How can I unload everything that can be reloaded from the database?

If they're marshaled before any of the associations are referenced then the referenced objects aren't dumped. But if the association has been loaded, how can I unload it? AssociationProxy.reset doesn't seem to do it. It seems that after the AssociationProxy has been touched at all then dumping the object causes the AssociationProxy to load everything.

Thanks!

Try calling these methods on your activerecord:

        clear_aggregation_cache         clear_association_cache

They are not private/protected so you can call them from outside an object as well.

Try calling these methods on your activerecord:

        clear_aggregation_cache         clear_association_cache

They are not private/protected so you can call them from outside an object as well.