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
On Jul 9, 6:42 pm, slava
<mikerin.sl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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.
>
> ----------
> I have seen a few threads with posts asking this question, but found
> no suitable solution or workaround..
> any ideas please.