belongs_to rails 6 code example Example: activerecord through class Doctor < ApplicationRecord has_many :patients, through: :consultation end