-
Notifications
You must be signed in to change notification settings - Fork 123
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
Add FosterAccount association to AdopterFosterProfile #497
Conversation
Hey, Erin! I took a look at your branch. My main comment that I think is affecting this, but not the direct cause of the error, is that this association seems incorrect: # app/models/adopter_foster_profile.rb:59
belongs_to :foster_account, class_name: “User”, foreign_key: :adopter_account_id I think this should be a simple reference to a However, that creates another issue. If the intention is for either an adopter_account OR foster_account, I think a polymorphic association for an account could work here. With that, each profile would have one associated account, of either foster type or adopter type. However, if the intention is for each Profile to have a reference to both, then we could add |
@mononoken , thank you for your feedback. After considering your input and reviewing the ticket, I agree that a user should be either an AdopterAccount, FosterAccount, or StaffAccount, not "And." I will proceed with your suggested changes, including creating a polymorphic association. Thank you. @kasugaijin , I'm double-checking with you before moving forward with these adjustments. |
@ErinClaudio So there are cases where a User could be an Adopter and a Fosterer
|
@kasugaijin Yup I will go that route |
Since this is the case, we do need to make one or both accounts optional too.
I'm thinking both accounts should be optional then, and we could write a custom validation to check the presence of at least one account. |
You know @mononoken was right, polymorphic might be a better suit here. My suggestion would require custom code and we should avoid that when we can, @ErinClaudio https://guides.rubyonrails.org/association_basics.html#polymorphic-associations
|
@mononoken @kasugaijin Thank you |
@ErinClaudio check out this draft PR I made to help you get the seeds to build - see the video as well for explanation. |
@kasugaijin working on this now with your direction. I will close this PR after I have made the required changes |
🔗 Issue
#449
✍️ Description
📷 Screenshots/Demos