Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

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

(As with Listing 11.4, the test for dependent :destroy is left as an exercise [Section 11.5].) Note that we actually have to include the class name for this association, i.e.,

 

because otherwise Rails would look for a ReverseRelationship class, which doesn’t exist. It’s also worth noting that we could actually omit the :source key in this case, using simply

has many :followers, through: :reverse relationships

 

since, in the case of a :followers attribute, Rails will singularize ‘‘followers’’ and automatically look for the foreign key follower_id in this case. I’ve kept the :source key to emphasizethe parallel structure with the has_many :followed_users association, but you are free to leave it off.

       With the code in Listing 11.16, the following/follower associations are complete, and all the tests should pass:  

$  bundle exec rspec spec/

 

This section has placed rather heavy demands on your data modeling skills, and it’s fine if it takes a while to soak in. In fact, one of the best ways to understand the associations is to use them in the web interface, as seen in the next section.  

 
 
 
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)