i wonder if the following is possible in Rails (seems like not), and if
not, whether such database structure is discouraged for some good
I roughly want to have
class Payment < ActiveRecord::Base
where purchase can be either TicketPurchase, or MembershipPurchase, so
to have also
class TicketPurchase < ActiveRecord::Base
class MembershipPurchase < ActiveRecord::Base
so things need to be polymorphic.
I want this correspond to the following database structure:
payments: id | amount | purchase_type
ticket_purchases: id | number | payment_id
membership_purchases: id | membership_type | payment_id
This does not seem to be possible in Rails, to use polymorphic
associations i would need to store the foreign key in payments table.
Am i right that it is not possible, and is there a good reason for
discouraging such associations?