Answers for "has many through rails"

1

has many through rails

class Physician < ApplicationRecord
  has_many :appointments
  has_many :patients, through: :appointments
end

class Appointment < ApplicationRecord
  belongs_to :physician
  belongs_to :patient
end

class Patient < ApplicationRecord
  has_many :appointments
  has_many :physicians, through: :appointments
end
Posted by: Guest on March-18-2021
2

activerecord through

class Doctor < ApplicationRecord
	has_many :patients, through: :consultation
end
Posted by: Guest on November-12-2020
0

rails join table macro

create_join_table :posts, :tags
Posted by: Guest on January-26-2020

Code answers related to "has many through rails"

Browse Popular Code Answers by Language