Ruby On Rails Classroom image

Neeraj  Amoli / 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
Neeraj  Amoli

Skills    Ruby On Rails

Qualifications :-
Location :-Dehradun,Dehradun,Uttrakhand,India
Description:-

I have 3 year experience as a Software Engineer. My Skilled are Android Development (Java), ROR Development .   


Explore
 

  Students (0)