Skip to content

Namespace ignored when fetching serializer for parent class #2291

@Charizard

Description

@Charizard

Consider an STI case with only parent class serializers and no separate child serializers. Now throw in different namespaces.

With model's:

class Parent < ActiveRecord::Base
end

class ChildA < Parent
end

class ChildB < Parent
end

Controllers & Serializers with namespaces looks like:
app/controllers/v1/parents_controller.rb
app/serializers/v1/parents_serializer.rb

Expected behavior vs actual behavior

Now when I render child records's from my V1::ParentsController controller, no serializer is being used (ActiveModel::Serializer::Null).

I've tracked down the issue to get_serializer_for method in ActiveModel::Serializer. When recursively calling get_serializer_for for super_class. Here, the namespace needs to be passed in as well.

Environment

Rails: 5
AMS Version: 1.10-stable

Additonal helpful information

Seems to be introduced in b29395b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions