나는 레일스에 새로운 브랜드이기 때문에 사소한 질문 일 수 있습니다. 자습서를 거치면서 has_many와 has_many를 통해 관계 식별자에 대해 읽었습니다. 내가 이해할 수없는 것은 그들 사이의 차이입니다. 환자와 환자 has_many : 의사와 그들이 관련이있을 것입니다 예를 들어, 내가 3 모델, 의사, 약속 및 환자레일 대 has_many 대 has_many through?
class Doctor< ActiveRecord::Base
has_many :appointments
has_many :patients, through: :appointments
end
class Appointment < ActiveRecord::Base
belongs_to :doctor
belongs_to :patient
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :doctors, through: :appointments
end
이 있다면 난 그냥 의사 has_many는 말할 수 없습니다? 이것을하기 위해 약속을 지키는 목적은 무엇입니까?
감사