You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the left-hand key isn't correct, you will get a cryptic error
undefined method `new' for nil:NilClass
I think a solution would be to update _build in renderer to something like:
def _build(object, exposures, klass)
raise "#{ object.class.name.to_sym } not found in the class option passed to jsonapi_render" if klass[object.class.name.to_sym].blank?
klass[object.class.name.to_sym].new(exposures.merge(object: object))
end
This way, if you've forgotten to map something there will be a helpful error message.
The text was updated successfully, but these errors were encountered:
I agree that the error message is not very helpful. However, checking for blank? is not enough, as it would still allow non-existing classes. Probably something along the lines of raise ... unless klass[...].is_a? JSONAPI::Serializable::Resource. @dawidof What do you think?
When rendering custom class / serializer mappings:
If the left-hand key isn't correct, you will get a cryptic error
I think a solution would be to update
_build
inrenderer
to something like:This way, if you've forgotten to map something there will be a helpful error message.
The text was updated successfully, but these errors were encountered: