#Active record association π¬π§
polymorphic relationships
Victor Barherenduba
Victor Barherenduba
1 min read
let's dive into the topic of polymorphic relationships, a crucial aspect of software development. Polymorphic relationships come in handy when you have an object that can take multiple forms.
For example, consider a scenario where you have a post model, a comment model, and a user model. You may want your users to be able to review not only the post but also other users' comments. In such a case, the review model can be made polymorphic and associated with the user, allowing the post and comment models to have many reviews through the reviewable association we created.
To learn more about the implementation of polymorphic relationships, please click on the following link
https://www.linkedin.com/posts/victor-barh_rubyonrails-association-polymorphic-activity-7035136437201088512-8dRp?utm_source=share&utm_medium=member_desktop
For example, consider a scenario where you have a post model, a comment model, and a user model. You may want your users to be able to review not only the post but also other users' comments. In such a case, the review model can be made polymorphic and associated with the user, allowing the post and comment models to have many reviews through the reviewable association we created.
To learn more about the implementation of polymorphic relationships, please click on the following link
https://www.linkedin.com/posts/victor-barh_rubyonrails-association-polymorphic-activity-7035136437201088512-8dRp?utm_source=share&utm_medium=member_desktop