Rails Associations

정시원·2022년 7월 31일
0

1:N Relations

class User < ApplicationRecord
	has_many :products, foreign_key: "owner_id", inverse_of: :owner
end

class Product < ApplicationRecord
	belongs_to :owner, class_name: "User", foreign_key: "owner_id"
end```
profile
Web Developer

0개의 댓글