Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
natonnelier opened this issue May 18, 2022 · 0 comments

Comments

@natonnelier
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant