Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes not tracked properly on instance pulled from collection #295

Closed
derekprior opened this issue Nov 6, 2014 · 6 comments · Fixed by #298
Closed

Changes not tracked properly on instance pulled from collection #295

derekprior opened this issue Nov 6, 2014 · 6 comments · Fixed by #298

Comments

@derekprior
Copy link

Consider:

u = User.all.first
u.changes

One would expect changes to be empty, but in fact every field is marked as changed. However:

u = User.find(1)
u.changes

Is empty as one would expect.

@chewi
Copy link
Contributor

chewi commented Nov 14, 2014

This happens for singular records returned from an association too.

@paulvt
Copy link

paulvt commented Jan 16, 2015

Indeed, clearing @changed_attributes is missing in several places. I have added for resource in Her::Model::Attributes.initialize_collection, but this doesn't solve it for single resource associations.

@paulvt
Copy link

paulvt commented Jan 16, 2015

Also added a clear to the fetch method of the various associations and now everything seems to be fine. When I have time I will prepare a pull request.

@chewi
Copy link
Contributor

chewi commented Jan 16, 2015

@paulvt, did you see my fix in #298? It should handle all cases.

@paulvt
Copy link

paulvt commented Jan 16, 2015

I overlooked your pull request, cheers!
This is much more elegant than clearing it all over the place. (I am still getting to grips with the intricate structure of model, relation, association, proxy, etc.)

@kvaggelakos
Copy link

I can confirm that this is still an issue. Doesn't seem like @chewi's PR has been merged yet.

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

Successfully merging a pull request may close this issue.

4 participants