Closed kevinmtrowbridge closed 7 years ago
This may be related? https://github.com/cerebris/jsonapi-resources/issues/654
@kevinmtrowbridge I believe you are correct; the change to the line you referenced was a mistake on my part.
@dgeb Thank you for correcting this. :+1:
I have a resource, where I have defined the model_name because, it's a namespaced STI model, and the name doesn't quite line up with what I want the resource name to be.
When I attempt to use the API to create one of these models, I get the following exception:
When I looked into it, I see the exception is happening in this method:
Basically the line
return @model if defined?(@model)
... it doesn't seem to be behaving correctly.@model
is nil ... butdefined?(nil)
actually returns "local-variable" -- so it's returning nil. This is causing the exception.The line was changed as a part of PR this commit:
https://github.com/cerebris/jsonapi-resources/commit/827f5db494ff8add581371db2fe6ac7f1c9abded#diff-e6cf31c573bd5f2277b1f16812943df4R986
Where it was changed from the original
return @model if @model
toreturn @model if defined?(@model)
...@DavidMikeSimon was this intentional? Apologies if I am off base? For now, I have monkey patched that line back to the original, and things are working again for me.
Thanks again for the gem! It has taken some investment from me but I am loving it and I believe in the long run this approach is really going to pay off.