Rails build a model from the has_many rel code example
Example 1: activerecord through
class Doctor < ApplicationRecord
has_many :patients, through: :consultation
end
Example 2: rails join table macro
create_join_table :posts, :tags
class Doctor < ApplicationRecord
has_many :patients, through: :consultation
end
create_join_table :posts, :tags