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

fix: Polymorphic + STI uniqueness check #1624

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Conversation

matsales28
Copy link
Member

@matsales28 matsales28 commented Mar 22, 2024

Instead of just initializing a new class that inherits from the parent class, we are initializing a new class but also overriding some method definitions. That is necessary because the Rails guides recommend that whenever you have a polymorphic association and STI you should override the ..._type column to use the type name of the base STI class.

https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Polymorphic+Associations

This should fix #1622

@matsales28 matsales28 force-pushed the fix-uniqueness-of-sti branch from 0f52c06 to ebc3c58 Compare March 22, 2024 21:10
@matsales28 matsales28 force-pushed the fix-uniqueness-of-sti branch from ebc3c58 to 3d4d893 Compare March 22, 2024 21:12
@matsales28 matsales28 changed the title fix: Maybe a fix? fix: Polymorphic + STI uniqueness check Apr 12, 2024
@matsales28 matsales28 marked this pull request as ready for review April 12, 2024 12:56
@matsales28 matsales28 requested a review from vsppedro as a code owner April 12, 2024 12:56
@matsales28
Copy link
Member Author

@vsppedro, this is now ready for you to take a look!

Copy link
Collaborator

@vsppedro vsppedro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@matsales28 matsales28 merged commit d04ae4e into main Apr 26, 2024
16 checks passed
@matsales28 matsales28 deleted the fix-uniqueness-of-sti branch April 26, 2024 18:30
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

Successfully merging this pull request may close these issues.

polymorph uniq check fails with 6.2
2 participants