lib/jsonapi/relationship.rb in jsonapi-resources-0.9.11 vs lib/jsonapi/relationship.rb in jsonapi-resources-0.9.12

- old
+ new

@@ -53,11 +53,17 @@ end end def type_for_source(source) if polymorphic? - resource = source.public_send(name) - resource.class._type if resource + # try polymorphic type column before asking it from the resource record + if source._model.respond_to?(polymorphic_type) + model_type = source._model.send(polymorphic_type) + source.class.resource_for(model_type)._type if model_type + else + resource = source.public_send(name) + resource.class._type if resource + end else type end end