I did this in rails 6 in my old database. This should work for rails> = 4.2.1 ( see here )
class Booking < ApplicationRecord
has_many :user_notes, as: :notable, foreign_type: :note_type, foreign_key: :type_id
end
class UserNote < ApplicationRecord
belongs_to :notable, polymorphic: true, foreign_type: :note_type, foreign_key: :type_id
end
source
share