开发者

Rails 3.0.x - why the other model is beeing updated?

开发者 https://www.devze.com 2023-02-19 04:47 出处:网络
I am trying to figure out things in code written by someone else. There are two models, with simple has_many relation (A->B).

I am trying to figure out things in code written by someone else. There are two models, with simple has_many relation (A->B).

Now the problem is, that while saving the "B" model, also the "A" model is updated in the database. Now, there is no callbacks of any sort, there is no special relation conditions (:autosave, etc), and also there is no Observers in the code.

The question is, what could be other things, which define this kind of behaviour?

Update: I am trying to debug the save process to track anything, but I am getting overwhelmend by the ammount of calls to internal active_record methods, so this 开发者_StackOverflowapprochach is getting useless.

Bonus question: How can I dump current model callbacks (in case, they were added in some manner which resistant to my grepping skills).


It could have :touch => true. That auto updates the association.


This turned out to be very complicated, internal application bug with Marshaling. In the result records fetched from cache were marked as not persisted, which forced ActiveRecord to create duplicate record while saving related objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消