N
N
NO2018-04-10 18:40:02
Ruby on Rails
NO, 2018-04-10 18:40:02

How to extend the has_and_belongs_to_many and has_many associations to refer to a single model object?

There is spray_products. Some of the spree_products may belong to other spree_products.
I created a table spree_product_childrens:

create_table :spree_product_childrens, id: false do |t|
  t.integer :product_id, null: false
  t.integer :children_id, null: false
  t.boolean :by_default, default: false
  t.boolean :necessarily, default: false
  t.boolean :in_set, default: false
end

How do I get a list of products where:
1) spree_products.id = spree_product_childrens.product_id
2) spree_product_childrens.children_id = spree_products.id

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question