Ruby On Rails Lesson
The Relationship Model
Our first step in implementing following users is to construct a data model, which is not as straightforward as it seems. Na¨ıvely, it seems that a has_many relationship should do: A user has_many followed users and has_many followers. As we will see, there is a problem with this approach, and we’ll learn how to fix it using has_many through.
It’s likely that many of the ideas in this section won’t seem obvious at first, and it may take a while for the rather complicated data model to sink in. If you find yourself getting confused, try pushing forward to the end, then read the section a second time through to see if things are clearer.