0
我有用户,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最好的方法?