Repository navigation
fix(associations): read singular ids key for has_many in frontmatter - #229
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
Conversation
has_many looked only for the pluralised key (editors_ids), but the docs use the Rails convention (editor_ids), so the collection silently fell back to the foreign key and came back empty. Accept the singular key first and keep the plural one as a fallback.
Contributor
|
The singular-key fix is good; please drop the id_for/Resource additions (it is an undocumented, out-of-scope feature) |
Keeps the singular ids key fix only, as requested in review.
Contributor
Author
|
Done: removed the (Drafted with Claude Code; not run locally by the author.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
has_manyignored the documentededitor_idsfrontmatter key and returned an empty collection.has_manybuilt the frontmatter key as"#{association_name}_ids"(editors_ids), but the docs (resources.md) and the skill template use the Rails convention (editor_ids,comment_ids). With the documented key the lookup never matched, fell back to foreign key matching and returned an empty collection without any warning.Fix: look up the singular
_idskey first and keep the plural one as a fallback, so existing content keeps working. The docs sentence is updated to name the singular form.Also:
records_for_idsdidit[:id], which raisesNoMethodErroron aPerron::Resourcetarget (the documentedhas_many :commentsexample). It now compares ids as strings against the record'sidmetadata, falling back to the slug for Resources.Tests: in
associations_test.rb:editor_idsresolves data records (red before the change),editors_idsstill works, and ids resolve against a Resource class by slug (red before: NoMethodError).This change was prepared with the help of an AI coding assistant (Claude) and submitted by a human who is responsible for it.