title: Need simple Rails many to many association logic
body: <p>I have a list of products and a list of categories. Also I have a mapping table <code>product_categories</code> which tells that products come under different categories and also category has many products. Here the category list is defined by admin. The number of categories is fixed, but can be varied. Now I need to get the list of products which are mapped with categories</p>
  
  <pre><code>product.rb
  has_many :product_categories, dependent: :destroy
  has_many :categories, through: :product_categories
  
  category.rb
  has_many :product_categories
  has_many :products, :through =&gt; :product_categories
  
  product_category.rb
  belongs_to :product
  belongs_to :category
  </code></pre>
  
  <p>I have written the code as:</p>
  
  <pre><code>ProductCategory.joins(:category).map(&amp;:category).uniq
  </code></pre>
  
  <p>Is there any way to simplify this line?</p>