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

Instance functions for update don't work correctly in before/after hook #106

Open
scottkf opened this issue Aug 23, 2012 · 3 comments
Open

Comments

@scottkf
Copy link

scottkf commented Aug 23, 2012

Not sure if this is intended or not

@scottkf
Copy link
Author

scottkf commented Aug 23, 2012

I wasn't entirely correct, before and after hooks do work on the instance/class, but you have to specify the exact method, I was mistaken in believing before(save) would trigger on update. There's still an issue where instance functions aren't working though, I'll look into that.

Edit: instance functions for update won't work in a before/after hook because update simply pushes the properties and not the object itself. A failing test: https://gist.github.com/3438974.

@ssevertson
Copy link
Contributor

Has anyone found a work-around for this 9 month old issue? It's biting me right now, as flatiron/restful uses Resource.update for PUT requests, and I've got a number of before/after hooks which expect a fully hydrated resource, not just the update properties.

@indexzero
Copy link
Member

@ssevertson Are you running with a cache? You can pull the fully hydrated resource from the cache based on the id.

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

No branches or pull requests

3 participants