You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it seems like the hooks are called 3 times (???)
beforeSave the first time tells me the expected value (this.status_id = null)
but before afterSave is called, beforeSave is called another 2 times having the original value of status_id... after those 3 beforeSave calls, the 3 afterSave calls are called, each of them having the original value of status_id in it, and not my expected value null
In my test file, there are 2 calls because somehow the Model is making an UPDATE query to set status_id to NULL and then making a new UPDATE query to set status_id to the previous one..
I think the hooks are being called 3 times because of the 2 associations. I only have one so it's called 2 times. I'm going to test with more associations.
Activity
dresende commentedon Jul 16, 2013
I'm going to take a closer look.
dresende commentedon Jul 16, 2013
I actually see 2
beforeSavecalls and 2afterSavecalls. Are you sure it's 3beforeSave? Can you show me your Person model ?dresende commentedon Jul 16, 2013
In my test file, there are 2 calls because somehow the Model is making an UPDATE query to set status_id to NULL and then making a new UPDATE query to set status_id to the previous one..
ctaepper commentedon Jul 16, 2013
ctaepper commentedon Jul 16, 2013
yes, i am 100% sure its 3 calls... in this file it is actually the imageresource i want to remove... but it also works with status
dresende commentedon Jul 16, 2013
I think the hooks are being called 3 times because of the 2 associations. I only have one so it's called 2 times. I'm going to test with more associations.
dresende commentedon Jul 16, 2013
This was nasty to debug, simple to fix :)
In the meantime, if you want to use the git version, do:
ctaepper commentedon Jul 16, 2013
i debugged myself for 2 hours before i gave up and left it to you ;-)
but thanks, will check it out tonight!