JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
`undefined method 'id' for nil:NilClass` when include null none primary key association
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Description
create_join_table :members, :articles, {id: false} do |t|
t.integer :article_id
t.string :polymorphicable_type
t.integer :polymorphicable_id
end
class MemberArticles < ApplicationRecord
belongs_to :article
belongs_to :polymophicable, polymorphic: true
end
class ArticleRecourse < JSONAPI::Resource
has_many :members, always_include_linkable_data: true
end
I want serialize articles polymorphic data througth join_table associated
when i use always_include_linkable_data: true or direct serialize members model also throw this exception.
should each resource model entity at least have _primary_key or id method? it is jsonapi-resources convention? If true, Maybe write in documents
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied Rails join-table and polymorphic-association example, starting at serialization of members with always_include_linkable_data enabled. Trace why the associated resource reaches the missing id method, then determine whether resources without a primary key are supported. Done means the behavior is corrected or the supported requirement is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100