Rick Denatale wrote:
> has_many (along with a belongs_to in the other class) if for a 1-n
> relation, but you are modelling an n-m relation.
> 
> class Company < ActiveRecord::Base
>    has_and_belongs_to_many :clients, :class_name => "Company",
> :join_table => :company_clients
>    has_and_belongs_to_many :suppliers, :class_name => "Company",
> :join_table => :company_suppliers
> end
> 
> I'm  not entirely sure that this works, but it's more likely to.
> 
> --
> Rick DeNatale
> 
> Blog: http://talklikeaduck.denhaven2.com/
> Twitter: http://twitter.com/RickDeNatale
> WWR: http://www.workingwithrails.com/person/9021-rick-denatale
> LinkedIn: http://www.linkedin.com/in/rickdenatale

Rick, thank you. With one small amendment, that does the job nicely. The 
only thing that was missing was ":association_foreign_key => :client_id" 
tacked onto the declaration (and a corresponding one for the suppliers).
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to