# 레일즈 다대다 관계 모델
레일즈 모델의 many-to-many association 설정 어떻게 하나요?
haesamq님의 답변
## has_many : through association
```
class Physician < ApplicationRecord
has_many :appointments
has_many :patients, through: :appointments
end
class Appointment < ApplicationRecord
belongs_to :physician
belongs_to :patient
end
class Patient < ApplicationRecord
has_many :appointments
has_many :physicians, through: :appointments
end
```
## 레퍼런스
+ https://guides.rubyonrails.org/association_basics.html#the-has-many-association