Association problem


#1

What is the correct way to define one to many association in rails 5.we
have currently the following migration files…we have to define
products and categories tables such that one category has many products.

class Category < ApplicationRecord
has_many :products, dependent: :destroy
end

class Product < ApplicationRecord
belongs_to :category, index: true
end