title: Rails has_and_belongs_to_many on 2 level association
body: <p>This is related to this previously asked <a href="https://stackoverflow.com/questions/40328322/rails-has-and-belongs-to-many-how-to-change-default-iforeign-key-and-show-list-o">question</a></p>
  <p>I have a has_and_belongs_to_many in place between Product and Supplier.</p>
  <p>In my view I use:</p>
  <pre><code>&lt;td&gt;&lt;%= product.suppliers.map {|supplier| supplier.NAME }.join(', ') %&gt;&lt;/td&gt;
  </code></pre>
  <p>To show list of suppliers comma separated on each row for each product in my table.</p>
  <p>I now need to show the same list on invoices index view. Invoices table has a column PRODUCT. I have already set belongs_to :product on Invoice model.</p>
  <p>I tried in my invoices index view:</p>
  <pre><code>&lt;td&gt;&lt;%= invoice.product.suppliers.map {|supplier| product.supplier.NAME }.join(', ') %&gt;&lt;/td&gt;
  </code></pre>
  <p>but it returns</p>
  <blockquote>
  <p>error undefined local variable or method `product'</p>
  </blockquote>
  <p>Why isn't that working? How can I fix it? Thanks in advance.</p>