사용자, PatientProfile 및 DoctorProfile 사이에 다형성 관계가 있습니다. Review
의 RESTful 경로를 만들려고합니다. 이것에 대한 가장 좋은 방법은 무엇입니까?Rails 다형성 RESTful 라우팅
class User
belongs_to :profile, polymorphic: true
class PatientProfile
has_one :user, as: :profile
has_many :reviews
class DoctorProfile
has_one :user, as: :profile
has_many :reviews
class Review
belongs_to :patient_profile
belongs_to :doctor_profile
한 가지 방법은 DoctorProfile
및 PatientProfile
대신 Users
를 사용하여 모두 별개의 경로를 만드는 것입니다. 이 방법의 단점은 2 명은 컨트롤러 DoctorProfileReviewsController
및 PatientProfileReviewsController
을해야한다는 것입니다 :
resources :patient_profile
resources :reviews
end
resources :doctor_profile
resources :reviews
end
이 모델 주어진 REST API를 구조화하는 가장 좋은 방법은 무엇입니까?