Ruby On Rails Classroom image

prateek  darmwal / Professional / 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
prateek  darmwal

Skills    Ruby On Rails

Qualifications :- High School - S.K.M. Sn. Sec. School, Haldwani, College/University - Graphic Era Hill University, Bhimtal,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:- I like to explore new technologies. I have skills in ruby on rails, php5, cakephp, jquery, javascript, html/css, java, c & c++. I love coding
Explore
 

  Students (0)