請幫 我有兩個表:如何使2個表之間的關聯在Rails的
hospitals
id | name | adress | main_doctor_id
doctors
id | name | contacts | bio | hospital_id
在車型:
hospital.rb
has_many :doctors
doctor.rb
belongs_to :hospital
但我在一個需要更多的關聯 - 每個醫院都有一個首席醫生(main_doctor)。如何創建這些關聯以及如何從這個main_doctor的Doctors獲取數據? 紅寶石2.0.0p353 的Rails 4.0.2
你說的「如何從醫生這個main_doctor數據」是什麼意思? –