Forum: Ruby on Rails Update join_table attributes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dan G. (Guest)
on 2006-01-25 04:41
I have two ActiveRecord classes that point at each other with a
"has_and_belongs_to_many" (habtm) relationship using a join table.  The
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
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
table using update_attributes.  This is a well documented shortcoming,
the solution everyone talks about is to override the update_attributes

The code (see the comments @ 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
defines HasAndBelongsToManyAssociations and you put in a method "foo"
call it, it won't be called either.

Would be grateful for any assistance.
Leon L. (Guest)
on 2006-01-25 05:13
(Received via mailing list)
Why not use edge rails :though?
Leon L. (Guest)
on 2006-01-25 05:19
(Received via mailing list)
This topic is locked and can not be replied to.