# Additional Fields in a Join Table

**URL:** <https://www.ruby-forum.com/t/additional-fields-in-a-join-table/58341>\
**Category:** Rails\
**Created:** [April 20, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/additional-fields-in-a-join-table/58341 "2006-04-20T18:26:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Lunde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@Ryan\_Lunde](https://www.ruby-forum.com/u/Ryan_Lunde)\
**Post date:** [April 20, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/additional-fields-in-a-join-table/58341/1 "2006-04-20T18:26:24Z")

</div>

Hi,

I am creating an order management web application, and have run into an  
issue over join tables. I am reading Agile Web D. and it says  
that I can put additional fields within my join tables, and they give  
the example of a date field.

I want to know if it is possible to do the following:

I have an orders table with the order information as well as an  
orders\_items table and an items table

It is a habtm relationship. I need to be able to update the item  
information for the specific order without changing it in the items  
table (ie. the items table holds the default values for the item, and  
the orders\_items table holds the updated values, such as price, and  
description)

Is it possible to leave the field names the same between both the  
order\_items table and the items table (both would have a price field).

I have been reading that there are problems when accessing these fields?  
Is this the proper way of doing this?

Thanks,  
Ryan L.

---

<div class="post-metadata">

**Author:** ![Ryan\_Lunde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@Ryan\_Lunde](https://www.ruby-forum.com/u/Ryan_Lunde)\
**Post date:** [April 20, 2006, 6:53pm UTC](https://www.ruby-forum.com/t/additional-fields-in-a-join-table/58341/2 "2006-04-20T18:53:05Z")

</div>

Attributes in HABTM tables have been superseded by has\_many and  
:through. You get the same benefits, but can also do more because the  
join table is now a full-blown model.

See:  
[http://wiki.rubyonrails.com/rails/pages/ThroughAssociations](http://wiki.rubyonrails.com/rails/pages/ThroughAssociations)  
[http://www.matthewman.net/articles/2006/01/06/rails-activerecord-goes-through](http://www.matthewman.net/articles/2006/01/06/rails-activerecord-goes-through)  
and of course the API docs at:

> **[ActiveRecord::Associations::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html)**
>
> Associations are a set of macro-like class methods for tying objects together through foreign keys.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Ryan\_Lunde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@Ryan\_Lunde](https://www.ruby-forum.com/u/Ryan_Lunde)\
**Post date:** [April 25, 2006, 4:51pm UTC](https://www.ruby-forum.com/t/additional-fields-in-a-join-table/58341/3 "2006-04-25T16:51:08Z")

</div>

Sorry about the slow response. So far this has worked for me. Thanks  
for your help!
