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 -- Posted via http://www.ruby-forum.com/.
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/rails-activerecord-goes-through and of course the API docs at: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html Hope this helps. Ryan Lunde wrote:> 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 > >
Sorry about the slow response. So far this has worked for me. Thanks for your help! Chris T wrote:> 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/rails-activerecord-goes-through > > and of course the API docs at: > http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html > > > Hope this helps. > > Ryan Lunde wrote: >> 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 >> >> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >