# Update join\_table attributes

**URL:** <https://www.ruby-forum.com/t/update-join-table-attributes/53094>\
**Category:** Rails\
**Created:** [January 25, 2006, 3:41am UTC](https://www.ruby-forum.com/t/update-join-table-attributes/53094 "2006-01-25T03:41:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcgrigsby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5e925/32.png) [@dcgrigsby](https://www.ruby-forum.com/u/dcgrigsby)\
**Post date:** [January 25, 2006, 3:41am UTC](https://www.ruby-forum.com/t/update-join-table-attributes/53094/1 "2006-01-25T03:41:44Z")

</div>

I have two ActiveRecord classes that point at each other with a  
“has\_and\_belongs\_to\_many” (habtm) relationship using a join table. The  
join  
table has an a few additional columns besides the \_id columns.

For those of you with the Agile Web Dev w/ Rails book, it’s exactly the  
same  
setup as the articles\<-\>articles\_users\<-\>users example on p240.

The habtm relationship is setup fine. I can see the linked data in  
instances of the objects.

The problem, though, is that I can’t update the extra columns in the  
join  
table using update\_attributes. This is a well documented shortcoming,  
and  
the solution everyone talks about is to override the update\_attributes  
code.

The code (see the comments @ [http://tinyurl.com/ey5qd](http://tinyurl.com/ey5qd)) starts like so:

module ActiveRecord  
module Associations  
class HasAndBelongsToManyAssociation  
def update\_attributes(record, join\_attributes = {})

The problem is, and here is why I’m writing, that this code isn’t called  
when you call update\_attributes. In fact, if you go and edit the file  
that  
defines HasAndBelongsToManyAssociations and you put in a method “foo”  
and  
call it, it won’t be called either.

Would be grateful for any assistance.

---

<div class="post-metadata">

**Author:** ![dcgrigsby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5e925/32.png) [@dcgrigsby](https://www.ruby-forum.com/u/dcgrigsby)\
**Post date:** [January 25, 2006, 4:19am UTC](https://www.ruby-forum.com/t/update-join-table-attributes/53094/2 "2006-01-25T04:19:49Z")

</div>

[http://www.matthewman.net/articles/2006/01/06/rails-activerecord-goes-through](http://www.matthewman.net/articles/2006/01/06/rails-activerecord-goes-through)

---

<div class="post-metadata">

**Author:** ![dcgrigsby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5e925/32.png) [@dcgrigsby](https://www.ruby-forum.com/u/dcgrigsby)\
**Post date:** [January 25, 2006, 4:13am UTC](https://www.ruby-forum.com/t/update-join-table-attributes/53094/3 "2006-01-25T04:13:47Z")

</div>

Why not use edge rails :though?
