-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Fix exception when using a resource with a composite primary/foreign key association #3335
base: main
Are you sure you want to change the base?
Conversation
Fix avo-hq#3334 Fix `NoMethodError: undefined method `to_sym' for an instance of Array` raised by this line when an association uses a composite primary key/foreign key.
Code Climate has analyzed commit 0a745ed and detected 0 issues on this pull request. View more on Code Climate. |
Thanks @filipegiusti! The approach I would take is to create a new model & resource which uses composite foreign keys and test that. Thank you for tackling this! |
I searched for a test file at PS: I also searched for some sort of coverage tool that would help pinpoint which tests cover that method and tried to get github copilot to find such tests, all without luck. |
Can you create a new spec next to this one and test only the composite behavior? |
@filipegiusti I can take over and create the test. Could you share some details about your environment setup? We don’t have any tables with composite primary or foreign keys, so I’m unsure how to configure the environment to test this change. |
It all started when we added the primary_key and foreign_key. We have these models. class Profile
has_one :membership, primary_key: %i[organization_id id], foreign_key: %i[organization_id profile_id], dependent: :destroy, inverse_of: :profile
end
class Membership
belongs_to :profile, primary_key: %i[organization_id id], foreign_key: %i[organization_id profile_id], inverse_of: :membership
end Both models have a primary key of id and an unique index of The edit page of Profile works, the exception is raised when Profile is attempted to be updated. We also have: class Resources::Profile < Avo::BaseResource
def fields
field :membership, as: :belongs_to, only_on: :show
end
end |
I might be able to look at this next week. |
This PR has been marked as stale because there was no activity for the past 15 days. |
That would be great, Thank you! |
Fixes #3334
Fix
NoMethodError: undefined method
to_sym' for an instance of Array` raised by this line when an association uses a composite primary key/foreign key.Checklist: