you need to use :source on the :through association<br><br>basically the way :through works is that it tries to infer the name of the name of the association, but in your case it can't<br><br>if you don't use :source, the has_many will try to find an association called :supported_products in the mechant class, but it can't, there is only :products, and that is what :source does, it says, &quot;look for this association in the join class&quot;.
<br><br>I'm new to :through as well, but this is what it seems to be intended for.<br><br>class Employee &lt; ActiveRecord::Base<br>&nbsp; has_many :enrolled_merchants, :class_name =&gt; &quot;Merchant&quot;, :foreign_key =&gt; &quot;enrollment_employee_id&quot;
<br>&nbsp; has_many :supported_merchants, :class_name =&gt; &quot;Merchant&quot;, :foreign_key =&gt; &quot;support_employee_id&quot;<br>&nbsp; has_many :enrolled_products, :through =&gt; :enrolled_merchants, :source =&gt; :products
<br>
&nbsp; has_many :supported_products, :through =&gt; :supported_merchants, :source =&gt; :products<br>

end<br><br>class Merchant &lt; ActiveRecord::Base<br>&nbsp; belongs_to :enrollment_employee, :class_name =&gt; &quot;Employee&quot;<br>
&nbsp; belongs_to :support_employee, :class_name =&gt; &quot;Employee&quot;<br>&nbsp; has_many :products<br>end<br><br>class Product &lt; ActiveRecord::Base<br>&nbsp; belongs_to :merchant<br>end<br><br><div><span class="gmail_quote">On 3/31/06, 
<b class="gmail_sendername">Chris Hall</b> &lt;<a href="mailto:christopher.k.hall@gmail.com">christopher.k.hall@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;"><span class="e" id="q_10a5144de8f60e8b_0"><br><div><span class="gmail_quote">On 3/31/06, <b class="gmail_sendername">Stephen Gerstacker</b> &lt;<a href="mailto:stephen@shortround.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
stephen@shortround.net</a>&gt; 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'.&nbsp;&nbsp;A<br>'Merchant' has many 'Products'.&nbsp;&nbsp;An 'Employee' has multiple 'Merchants',<br>depending on their relationship.&nbsp;&nbsp;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 &lt; ActiveRecord::Base<br><br>&nbsp;&nbsp;has_many :enrollment_merchants, :class_name =&gt; &quot;Merchant&quot;,
<br>:foreign_key =&gt; :enrollment_employee_id<br>&nbsp;&nbsp;has_many :support_merchants, :class_name =&gt; &quot;Merchant&quot;, :foreign_key<br>=&gt; :support_employee_id<br><br>end<br><br>And my Merchant class looks like this:
<br>
<br>class Merchant &lt; ActiveRecord::Base<br><br>&nbsp;&nbsp;belongs_to :enrollment_employee, :class_name =&gt; &quot;Employee&quot;,<br>:foreign_key =&gt; &quot;enrollment_employee_id&quot;<br>&nbsp;&nbsp;belongs_to :support_employee, :class_name =&gt; &quot;Employee&quot;, :foreign_key
<br>=&gt; &quot;support_employee_id&quot;<br><br>&nbsp;&nbsp;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 &lt; ActiveRecord::Base<br><br>&nbsp;&nbsp;has_many :enrollment_merchants, :class_name =&gt; &quot;Merchant&quot;,<br>:foreign_key =&gt; :enrollment_employee_id<br>&nbsp;&nbsp;has_many :support_merchants, :class_name =&gt; &quot;Merchant&quot;, :foreign_key
<br>=&gt; :support_employee_id<br><br>&nbsp;&nbsp;has_many :enrollment_products, :through =&gt; :enrollment_merchants<br>&nbsp;&nbsp;has_many :support_products, :through =&gt; :support_merchants<br><br>end<br><br>But that obviously doesn't work.&nbsp;&nbsp;Can I make this work somehow?
<br><br>--<br>Posted via <a href="http://www.ruby-forum.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.ruby-forum.com/</a>.<br>_______________________________________________<br>Rails mailing list
<br><a href="mailto:Rails@lists.rubyonrails.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Rails@lists.rubyonrails.org
</a><br><a href="http://lists.rubyonrails.org/mailman/listinfo/rails" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.rubyonrails.org/mailman/listinfo/rails</a><br></blockquote></div><br>


</span></div></blockquote></div><br>