Fix error where polymorphic relation not set#54
Fix error where polymorphic relation not set#54SebastianEdwards wants to merge 1 commit intovenuu:masterfrom
Conversation
Currently if you declare a polymorphic association on a resource `AuthorizingProcessor.related_models` will error out if you try to create a record without having that relation set. The `assoc_value` will be `nil` which is not a `Hash` so the polymorphic relationship code route is not be taken. This fixes that.
|
Thanks! Are you able to come up with a test scenario for this? We've one polymorphic association in the spec dummy app, |
|
Hiya @SebastianEdwards, are you able to show me an example of a If you could provide an example with this level of detail, that would be super awesome |
|
Ping @SebastianEdwards ☝️ I'm waiting for your answer before I'm able to figure this out. |
|
Cool - will come back with a test soon. Bit swamped w/ work at the moment! |
|
Hiya @SebastianEdwards, still waiting here
|
|
There is also a problem when we have class User
belongs_to :nationality, class_name: 'Country'
end
"data": {
"type": "users",
"id": "1",
"relationships": {
"nationality": null
}
}
}So we need to add same functionality ( now we have an error: {
"errors": [
{
"title": "Record not found",
"detail": "The record identified by could not be found.",
"code": "404",
"status": "404"
}
]
} |
|
Released v1.0.0.alpha4 with the fix to @jpalumickas' issue with the PATCH request. I'm afraid the issue that @SebastianEdwards has is still a mystery to me, as I haven't received the details I need to understand what this issue is about. |
|
@SebastianEdwards, still waiting for more details on your issue. I'd love if we could fix the issue you're facing and have a spec ensuring we don't break it in the future. See #54 (comment) for what I'd need to understand what this issue is about. |
|
Hi @valscion, Sorry I've been such a slack bastard with this. If only good intentions could write tests! My issue was exactly what @jpalumickas had described - my front-end code would send null in the place of a Looks like the fix has been merged in another PR with tests so happy days! (Thanks @jpalumickas!) |
|
Can you confirm that your case is solved by the fix done in #69? |
|
Yup. #69 fixes the issue - will close this. |
|
Thanks for following up with the confirmation! ❤️ |
Currently if you declare a polymorphic association on a resource
AuthorizingProcessor.related_modelswill error out if you try to create a record without having that relation set. Theassoc_valuewill benilwhich is not aHashso the polymorphic relationship code route is not be taken. This fixes that.