Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3|Last
Lessons:-Followers

Notice how we switch subjects using the subject method, replacing @user with other_user, allowing us to test the follower relationship in a natural way:

 

As you probably suspect, we will not be making a whole database table just to hold reverse relationships. Instead, we will exploit the underlying symmetry between followers and followed users to simulate a reverse_relationships table by passing followed_id asthe primary key.In otherwords,wherethe relationships association uses the follower_id foreign key,

has many :relationships, foreign key:  "follower id"

 

the reverse_relationships association uses followed_id:  

has many :reverse relationships, foreign key:  "followed id"

 

The followers association then gets built through the reverse relationships, as shown in Listing 11.16.

 
 
 
image
Pooja   Negi

Skills    Ruby On Rails

Qualifications :- High School - SSN high school, College/University - HNBGU, College/University - SRHU,
Location :-Ranipokhari,Rishikesh,Uttarakhand,India
Description:- Student
Explore
 

  Students (0)