Ruby On Rails Classroom image

Anil  Bist / 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
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)