has_many :through habtm

Here is my setup:

class Product < ActiveRecord::Base   belongs_to :catalog   has_and_belongs_to_many :product_groups end

class ProductGroup < ActiveRecord::Base   belongs_to :catalog   has_and_belongs_to_many :products end

class Catalog < ActiveRecord::Base   has_many :product_groups   has_many :products, :through => :product_groups end

I get: Invalid source reflection macro :has_and_belongs_to_many for has_many :products, :through => :product_groups. Use :source to specify the source reflection.

As written, there's no direct way to do this association in Rails. But wouldn't it be sufficient to use a plain has_many :products in Catalog? You've got a corresponding belongs_to in Product...

--Matt Jones

yeah, I think it is sufficient. thanks.