Items -> ReservationWithItems -> Checkout -> Payment -> User
Course -> Attendes -> RegistrationForCourse -> Checkout -> Payment -> User
YearlyFee -> Checkout -> Payment -> User
我想在我的山区俱乐部创建带有手柄预订,年费和培训课程的应用程序。我想组织我的代码使用Checkout课程,该课程将收集预订或年费等产品或课程注册,然后我就可以为他们创建付款。
以下是我的想法如何实现,但我不确定我是否应该在这里使用多态。
Db::Item(name:, cost:)
has_many :reservations, through: :reservations_items
Db::ReservationsItems
belongs_to :item
belongs_to :reservation
Db::Reservation(description:, state:, start_date:, end_date:)
has_many :items, through: :reservations_items
belong_to :payable, polymorphic: true
Db::Checkout
has_many :reservations, as: :payable
has_many :yearly_fees, as: :payable
has_one :payment
belongs_to :user
Db::Payment
belongs_to :checkout
-----
Db::YearlyFee(cost:, :year)
belong_to :payable, polymorphic: true
这种系统是否存在某些最佳实践或示例?