I have a really weird problem I was hoping someone might have some insight on.
I have a button that is linked to an action to update then save a model:
// component.js
resolveInvestigation(itemID) {
let item = this.get('store').peekRecord('customer-investigations-item', itemID)
set(item, 'status_id', 1)
item.save()
}
// template.hbs
<button {{action "resolveInvestigation" data.id}}>
The button is part of a bootstrap ‘card’ style component so there are a few instances of it on the page.
If I click the button on card A I get a console error as follows:
Error: No model was found for 'customer-investigation-item'
I have no idea why it has decided to drop the s from ‘investigations’ - it doesn’t even make the PATCH call.
Weirdly, after this initial interaction, if I click the button on a different instance of the component the model saves with no error. It doesn’t seem to matter which instance is clicked first either (I’ve tried reloading the page and clicking a different instance first and had the same results).
I’m at a bit of a loss. I thought it might have been some weirdness with native class syntax or the @action
decorator but I reverted to a classic component with no improvement. I’m also saving this model with the same methodology elsewhere in the application with no problems. Has anyone got a best guess?
EDIT:
I added an updateRecord
function to the adapter to and console logged the snapshot and type from the save attempt. The modelName
in both cases is customer-investigations-item
so I have no idea where it is getting customer-investigation-item
from