When making a request to the endpoint /appointments?include=appointment_requests, the related appointment requests are not being included in the response.
Here is my code for the appointment resource:
class AppointmentResource < ApplicationResource
primary_endpoint '/appointments'
self.model = Appointment
has_many :appointment_requests, resource: CustomerPortal::AppointmentRequestResource
end
and here is the appointment request resource:
class AppointmentRequestResource < ApplicationResource
primary_endpoint '/appointment_requests'
self.model = AppointmentRequest
filter :appointment_id, :integer
belongs_to :appointment, resource: CustomerPortal::AppointmentResource
end
If however, I add an alias name for the appointment_requests relationship on the appointment model like this:
alias_attribute :requests, :appointment_requests
and then I update the has_many association on the appointment resource to be requests instead of appointment_requests, the appointment requests are included in the response as expected.
So it seems to be working fine as long as there isn't an underscore in the relationship name 🤔
When making a request to the endpoint
/appointments?include=appointment_requests
, the related appointment requests are not being included in the response.Here is my code for the appointment resource:
and here is the appointment request resource:
The response body looks like this:
If however, I add an alias name for the appointment_requests relationship on the appointment model like this:
alias_attribute :requests, :appointment_requests
and then I update the has_many association on the appointment resource to be
requests
instead ofappointment_requests
, the appointment requests are included in the response as expected.So it seems to be working fine as long as there isn't an underscore in the relationship name 🤔