<br><div><span class="gmail_quote">On 3/31/06, <b class="gmail_sendername">Stephen Gerstacker</b> <<a href="mailto:stephen@shortround.net">stephen@shortround.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Quick Overview:<br><br>I have an 'Employee', some 'Merchants' and some 'Products'. A<br>'Merchant' has many 'Products'. An 'Employee' has multiple 'Merchants',<br>depending on their relationship. For example, the Employee may be the
<br>enrollment contact for one merchant and the support contact for another.<br>Therefore, my Employee class looks like this:<br><br>class Employee < ActiveRecord::Base<br><br> has_many :enrollment_merchants, :class_name => "Merchant",
<br>:foreign_key => :enrollment_employee_id<br> has_many :support_merchants, :class_name => "Merchant", :foreign_key<br>=> :support_employee_id<br><br>end<br><br>And my Merchant class looks like this:<br>
<br>class Merchant < ActiveRecord::Base<br><br> belongs_to :enrollment_employee, :class_name => "Employee",<br>:foreign_key => "enrollment_employee_id"<br> belongs_to :support_employee, :class_name => "Employee", :foreign_key
<br>=> "support_employee_id"<br><br> has_many :products<br><br>end<br><br>I'd like to use :through in the association so that I can get all of the<br>enrollment products and all of the support products for the Employee.
<br>Ideally it would look like:<br><br>class Employee < ActiveRecord::Base<br><br> has_many :enrollment_merchants, :class_name => "Merchant",<br>:foreign_key => :enrollment_employee_id<br> has_many :support_merchants, :class_name => "Merchant", :foreign_key
<br>=> :support_employee_id<br><br> has_many :enrollment_products, :through => :enrollment_merchants<br> has_many :support_products, :through => :support_merchants<br><br>end<br><br>But that obviously doesn't work. Can I make this work somehow?
<br><br>--<br>Posted via <a href="http://www.ruby-forum.com/">http://www.ruby-forum.com/</a>.<br>_______________________________________________<br>Rails mailing list<br><a href="mailto:Rails@lists.rubyonrails.org">Rails@lists.rubyonrails.org
</a><br><a href="http://lists.rubyonrails.org/mailman/listinfo/rails">http://lists.rubyonrails.org/mailman/listinfo/rails</a><br></blockquote></div><br>