Hello everybody, I would like to configure this configuration: clients ------- id name city products -------- id name price clients_products ---------------- client_id product_id date ip_address ...But I am not sure about this following config because clients_products table had "date" and "ip_address" attributs. Do you think I need to build a model for clients_products able? class Client < ActiveRecord::Base has_and_belongs_to°many :products end class Product < ActiveRecord::Base has_and_belongs_to°many :clients end Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, The habtm relationship doesn´t work when the inner table has other data then the id's. So you will need a model for it and then you'll need the has_many :through for having clients at products and vice-versa. On Sun, May 4, 2008 at 1:01 PM, David B. <rails-mailing-list@andreas-s.net> wrote:> > Hello everybody, > > I would like to configure this configuration: > > clients > ------- > id > name > city > > > products > -------- > id > name > price > > > clients_products > ---------------- > client_id > product_id > date > ip_address > > > > ...But I am not sure about this following config because > clients_products table had "date" and "ip_address" attributs. Do you > think I need to build a model for clients_products able? > > class Client < ActiveRecord::Base > has_and_belongs_to°many :products > end > > class Product < ActiveRecord::Base > has_and_belongs_to°many :clients > end > > > Thanks > -- > Posted via http://www.ruby-forum.com/. > > > >-- Rafael Gaspar - rafael.gaspar@gmail.com <http://www.eucomomaca.com> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hum, okay... Thank you :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---