Rails Self-Referential Relationships - DEV Community
05-May-2023 508
In a self-referential relationship a class can interact with itself using a join table. While brainstorming some ideas for my new Rails project I found the topic of self-referential has_many, throughrelationships. After reading about it I decided to try it out to see if it would fit what I wanted to do. At first it was a little confusing but after some practice with it, I found that it was very simple. I didn’t end up using this kind of relationship for my project but it was really fun to learn about it. These sort of relationships are very commonly used in social media. Some examples are followers, friendships, messages, and friend requests. I found that the messages example was the easiest to understand.
Rails Self-Referential Relationships - DEV Community #ruby #rubydeveloper #rubyonrails #Rails #Self-Referential #Relationships #Community #dev https://rubyonrails.ba/link/rails-self-referential-relationships-dev-community