spraypaint.js
spraypaint.js copied to clipboard
Relationship keys are not getting converted to camelCase
When defining a model, it appears that only attributes are getting converted to camelCase but relationship keys have to be defined in snake case or else I get the error Unknown type "appointment_requests"
I have an Appointment model that is currently setup like this:
const Appointment = ApplicationRecord.extend({
static: {
jsonapiType: "appointments",
},
attrs: {
appointmentRequests: hasMany(),
},
});
It has a has many relationship to the AppointmentRequests model that looks like this:
const AppointmentRequests = ApplicationRecord.extend({
static: {
jsonapiType: "appointmentRequests",
},
attrs: {
appointment: belongsTo(),
startTime: attr(),
},
});
However, I currently have to change appointmentRequests
to appointment_requests
in both models in order to be able to access the related appointment requests from an appointment record. It seems like I should be able to define the relationships in camelCase since other attributes get converted from snake_case to camelCase correctly. Has anyone else seen or run into this issue before?
@nataliepatton13 I set jsonapiType
to what comes from the server, which is in snake_case. Then you can use camelCase relationship names everywhere, such as appointmentRequests
.