# HABTM to call after\_update?

**URL:** <https://www.ruby-forum.com/t/habtm-to-call-after-update/120841>\
**Category:** Rails\
**Created:** [November 21, 2007, 1:22am UTC](https://www.ruby-forum.com/t/habtm-to-call-after-update/120841 "2007-11-21T01:22:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [November 21, 2007, 1:22am UTC](https://www.ruby-forum.com/t/habtm-to-call-after-update/120841/1 "2007-11-21T01:22:16Z")

</div>

Railsters:

Given two models, Frog and Pond, suppose we have a habtm between them

- frogs\_ponds.

This statement…

frog.ponds \<\< Pond.new

…does not trigger any frog.after\_update calls.

How can we connect frogs to ponds and update correctly when the link  
itself changes - not the frogs or ponds?

–  
Phlip

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [November 21, 2007, 1:43am UTC](https://www.ruby-forum.com/t/habtm-to-call-after-update/120841/2 "2007-11-21T01:43:18Z")

</div>

> Association callbacks might float your boat:[BarryKeenan.blogspot.com Learning Rails, Ruby and Other Things...](http://barrykeenan.blogspot.com/2007/08/association-callbacks.html)

Outrageous - that was it! (and note we used :after\_add,  
because :update\_ is irrelevant to an association table.)

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [November 21, 2007, 1:31am UTC](https://www.ruby-forum.com/t/habtm-to-call-after-update/120841/3 "2007-11-21T01:31:37Z")

</div>

On 21 Nov 2007, at 00:21, Phlip wrote:

> …does not trigger any frog.after\_update calls.
> 
> How can we connect frogs to ponds and update correctly when the link  
> itself changes - not the frogs or ponds?

Association callbacks might float your boat:

> **[Association Callbacks](http://barrykeenan.blogspot.com/2007/08/association-callbacks.html)**
>
> Similiar to the normal callbacks that hook into the lifecycle of an Active Record object, you can also define callbacks that get trigged whe...

Fred
