Forum: Ruby on Rails association problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2f55d6b84c2a039e1dba9f1a895efd23?d=identicon&s=25 Anmol K. (Guest)
on 2017-04-30 10:44
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

class Product < ApplicationRecord
  belongs_to :category, index: true
This topic is locked and can not be replied to.