Skip to content

Trying to render STI classes gives a cryptic error #113

Description

@faissalMT

Something similar was briefly mentioned here:
#68 (comment)
When a relation contains an item of an STI type jsonapi-rails isn't able to infer the renderer for it and instead it only crashes with the error:

ActiveModel::UnknownAttributeError:
       unknown attribute 'url_helpers' for PrimarySubject.

At the very least a helpful error message would go a long way here, as this is difficult to debug yourself.
The workaround is to manually specify all classes:

{
          Subject: SerializableSubject,
          PrimarySubject: SerializableSubject
          SecondarySubject: SerializableSubject
          ModernLanguagesSubject: SerializableSubject,
          FurtherEducationSubject: SerializableSubject
}

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