Skip to content

Inherited resources not rendering parent's attributes (w/ Null Adapter and polymorphism) #416

Description

@natonnelier

I have the following Resource:

module Api::V2
  class RecognitionResource < BaseResource
    self.adapter = Graphiti::Adapters::Null
    self.polymorphic = [BarcodeResource, TokenResource]

    belongs_to :page, foreign_key: :page_id, except: [:writable], resource: PageResource

    attribute(:confidence, :float)
    attribute(:coordinates, :hash)
    attribute(:kind, :string)
    attribute(:value, :string)
    attribute(:id, :string)
    attribute(:page_id, :string)
  end
end

From which this resource inherits:

module Api::V2
  class TokenResource < RecognitionResource
    self.model = Recognitions::Token
    self.type = "text"
end

I should add they don't use ActiveRecord models but instead plain ruby objects (with attr_accessors in place for every attribute).
Now, if I move the attributes and association to the child resource this works fine. But if I leave them in the parent resource it renders no attributes and the association is not loaded.

Is there some library I should import?
Thanks

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

    bugVerified to reproduce; see needs-repro for unconfirmedneeds reproNeeds a reproduction before triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions