내 설정 : 내 응용 프로그램 LogedIn - 사용자에은 다 대다 : has_many : 레일 통해 사용자 테이블 관계 문제는 모델 4
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 :physicians, :through => :appointments
end
는 하나 의사, 환자 또는 내가 가진 관리자입니다 이해하는 방법을 의사와 약속 환자 관계의 작동하지만이 설정하는 방법에 대한 사용자 모델과 테이블이
class User_type < ActiveRecord::Base
belongs_to :doctors, class_name: "USER"
belongs_to :patients, class_name: "USER"
end
에 내가 여기에 중요한 자기 연결을 잃었 알고하지만 난 그렇게 할, 또는 수있는 방법을 다른 방법 이를 위해이 모델과 테이블을 설정해야합니다. 미리 감사드립니다.
나는 오타를 바로 잡았지만 내 실제 질문은 모델과 테이블에 관한 것입니다. 사용자 (들)는 어떻게 보일까요? –