Forum: Ruby on Rails Storing additional data on join tables with Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-05-06 19:19
(Received via mailing list)
Hi there

I need to store additional attributes on join table. Searching the
Wiki [1] revealed two possible methods:

1) push_with_attributes, as described by Justin Palmer [2].
Unfortunately, "this method is now deprecated" [3]. Even if it wasn't,
there seem to be inherent problems with that approach, for example
with updating those additional attributes, though Joshua Muheim have
provided us with a plugin for that [4].

2) promote the join-table to a full module. This approach seems to
integrate better with Rails, and even a newb like me can sense that it
has a lesser chance of rubbing ActiveRecord's magic the wrong way,
thereby breaking something. Still, that habtm association is just an
association, not a model. I wouldn't want to make it a model if I
could help it.

So, what's the best practice for storing additional data on join
tables with Rails?

-Alder

-------------------
[1] http://wiki.rubyonrails.com/rails/pages/has_and_be...
[2]
http://encytemedia.com/blog/articles/2005/06/15/st...
[3]
http://api.rubyonrails.com/classes/ActiveRecord/As...
[4]
http://wiki.rubyonrails.com/rails/pages/Update+has...
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 Peter Michaux (Guest)
on 2006-05-06 19:23
(Received via mailing list)
Make the join table a full model and look in the docs for has_many
:through

http://api.rubyonrails.org/classes/ActiveRecord/As...

Peter
9f0f89bbd9e1ecfbaab6584e429b7a2f?d=identicon&s=25 Josh Susser (jsusser)
on 2006-05-06 19:54
Alder Green wrote:
> So, what's the best practice for storing additional data on join
> tables with Rails?

http://blog.hasmanythrough.com/articles/2006/04/20...

--
Josh Susser
http://blog.hasmanythrough.com
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-05-06 21:10
(Received via mailing list)
On 5/6/06, Josh Susser <josh@hasmanythrough.com> wrote:
> Alder Green wrote:
> > So, what's the best practice for storing additional data on join
> > tables with Rails?
>
> http://blog.hasmanythrough.com/articles/2006/04/20...
>
> --
> Josh Susser
> http://blog.hasmanythrough.com

Thanks Josh!

"has_many :through" is awesome, and your article is very informative.

Certainly, through associations are the proper way to do what I want.

Regards,
Alder
This topic is locked and can not be replied to.