Skip to content

Trying to render STI classes gives a cryptic error #113

@faissalMT

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions