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
Raising as an issue in case I don't understand why it's implemented this way, but If you specify the serializer similar to:
JSONAPI::Serializer.serialize(model, namespace: Api::V1, serializer: UserStorySerializer, include: ['foo'], context: context)
and model is a User (not a UserStory), find_serializer_class_name will return Api::V1::UserSerializer, which fails when JSONAPI::Serializer.find_serializer(root_object, options) is
called and later used via serializer.has_many_relationships.has_key?(unformatted_attr_name)
From: /Users/myuser/.rvm/gems/ruby-2.3.3@rails5/gems/jsonapi-serializers-1.0.0/lib/jsonapi-serializers/serializer.rb @ line 237 JSONAPI::Serializer.find_serializer_class_name:
236: def self.find_serializer_class_name(object, options)
=> 237: if options[:namespace]
238: return "#{options[:namespace]}::#{object.class.name}Serializer"
239: end
240: if object.respond_to?(:jsonapi_serializer_class_name)
241: return object.jsonapi_serializer_class_name.to_s
242: end
243: "#{object.class.name}Serializer"
244: end
I think it should use the options[:serializer] directly if specified in the options
The text was updated successfully, but these errors were encountered:
uhrohraggy
changed the title
Serializing a different type of object while specifying the serializer fails with includes
Serializing a different type of object while specifying the serializer fails to find relationships with includes
May 18, 2017
Raising as an issue in case I don't understand why it's implemented this way, but If you specify the serializer similar to:
JSONAPI::Serializer.serialize(model, namespace: Api::V1, serializer: UserStorySerializer, include: ['foo'], context: context)
and
model
is aUser
(not aUserStory
), find_serializer_class_name will return Api::V1::UserSerializer, which fails whenJSONAPI::Serializer.find_serializer(root_object, options)
iscalled and later used via
serializer.has_many_relationships.has_key?(unformatted_attr_name)
From: /Users/myuser/.rvm/gems/ruby-2.3.3@rails5/gems/jsonapi-serializers-1.0.0/lib/jsonapi-serializers/serializer.rb @ line 237 JSONAPI::Serializer.find_serializer_class_name:
I think it should use the options[:serializer] directly if specified in the options
The text was updated successfully, but these errors were encountered: