Ruby On Rails Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  |1 | 2 | 3 | 4|Last
Lessons:- A Problem with the Data Model (and a Solution)

  A Problem with the Data Model (and a Solution)

 

As a first step toward constructing a data model for following users, let’s examine a typical case. For instance, consider a user who follows a second user: We could say that, e.g., Calvin is following Hobbes, and Hobbes is followed by Calvin, so that Calvin is the follower and Hobbes is followed. Using Rails’ default pluralization convention, the set of all users following a given user is that user’s followers, and user.followers is an array of those users. Unfortunately, the reverse doesn’t work: By default, the set of all followed users would be called the followeds, which is ungrammatical and clumsy

 

 

We could call them following, but that’s ambiguous: In normal English, a ‘‘following’’ is the set of people following you, i.e., your followers—exactly the opposite of the intended meaning. Although we will use ‘‘following’’ as a label, as in ‘‘50 following, 75 followers,’’ we’ll use ‘‘followed users’’ for the users themselves, with a corresponding user.followed_users array.2

       This discussion suggests modeling the followed users as in Figure 11.6, with a followed_users table and a has_many association. Since user.followed_users should be an array of users, each row of the followed_users table would need to be a user, as identified by the followed_id, together with the follower_id to establish

 
 
 
image
Anil  Bist

Skills    Ruby On Rails

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)