Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Innately handle nested model disposal #758

Open
ondreian opened this issue Jan 30, 2014 · 1 comment
Open

Innately handle nested model disposal #758

ondreian opened this issue Jan 30, 2014 · 1 comment

Comments

@ondreian
Copy link

I have found that as my Chaplin applications grow it makes sense to nest models, some working examples might be a Post with a child collection of images that are used in subviews.

However, upon saving/changing to a different instance of the parent model a quasi-Singleton/ghost model bug can emerge on the nested models, so that a complete new Post may be initialized but somehow the images are referencing another post's images.

Initially I solved this by manually disposing my nested models via a super in Model::dispose method of every model, but recently I patched my version of Chaplin.Model::dipose to contain the following:

attr.dispose?() for attr of @attributes

I am not sure if there is a reason that the Model::dispose method doesn't already contain this fallback for nested models, but I have not noticed any unintended results from it, and it has made my model declaration a bit more straightforward.

@paulmillr paulmillr reopened this May 15, 2015
@ondreian
Copy link
Author

@paulmillr sorry, was just going through and closing issues that seemingly were stagnant in my feed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants