Sitelet https://github.com/jsonapi-serializer/jsonapi-serializer/issues/175
Skip to content

Way to resolve correct serializer for a model? E.g. this gem's equivalent to: ActiveModelSerializers::SerializableResource.new(record).as_json #175

Description

@KelseyDH

Expected Behavior

I am looking at migrating a project using ActiveModelSerializers following the JSON API spec over to this gem, and I'm searching for a generic way for this gem to resolve the correct serializer when given an ActiveRecord model. This is because the existing base controllers use this approach to find the correct serializer. I couldn't find anything in the documentation describing a way to do this.

E.g. is there a way I can call JSONAPI::SerializableResource.new(record, include: '**').as_json to resolve which serializer to use for a given record. All the examples in the docs suggest you need to manually specify the correct serializer.

Actual Behavior

Can't find any method doing this?

Steps to Reproduce the Problem

Specifications

  • Version: 2.2.0
  • Ruby version: 2.5.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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