i think there ara two ways of relate products and categories ,
basically i want to fix one product(e.g hp dv7…) to some categories
(notebook,17"notebooks…)
i made a table named categorization(incuding category_id,product_id
fields) then in models i write these codes below
class Product < ActiveRecord::Base
has_many :categories, :through => :categorizations
has_many :categorizations
end
class Categorization < ActiveRecord::Base
belongs_to :product
belongs_to :kategori
end
class Category < ActiveRecord::Base
has_many :products, :through =>:categorizations
has_many :categorizations
end
i’m not sure how rails complain which field will be use for relation
products and categories in categorization table(this is missing chain
i think)…anyway if we continue , i have to make form (creating
new product and add a new row in categorization table for identify
categories of product we want to add at the same time )
which method should i use for add new product and its categories at
the same time?