Forum: Ruby on Rails Additional Fields in a Join Table

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.
3b87f1ad86f6a44241832314873e8d54?d=identicon&s=25 Ryan Lunde (Guest)
on 2006-04-20 18:26
Hi,

I am creating an order management web application, and have run into an
issue over join tables. I am reading Agile Web Development 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 Lundie
58c6efb8466b9f85155fe6aa9fc37fce?d=identicon&s=25 Chris T (Guest)
on 2006-04-20 18:53
(Received via mailing list)
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://www.matthewman.net/articles/2006/01/06/rail...
and of course the API docs at:
http://api.rubyonrails.org/classes/ActiveRecord/As...

Hope this helps.
3b87f1ad86f6a44241832314873e8d54?d=identicon&s=25 Ryan Lundie (Guest)
on 2006-04-25 16:51
(Received via mailing list)
Sorry about the slow response.  So far this has worked for me. Thanks
for your help!
This topic is locked and can not be replied to.