Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5|
Lessons:-A Working Follow Button the Standard Way

This works because the user should be redirected before the application ever tries to retrieve the relationship with this id.

      The controller code needed to get these tests to pass is remarkably concise: We just retrieve the user followed or to be followed, then follow or unfollow the user using the relevant utility method. The full implementation appears in Listing 11.34.

 

We can see from Listing 11.34 why the security issue mentioned above is minor: If an unsigned-in user were to hit either action directly (e.g., using a command-line tool), current_user would be nil, and in both cases the action’s second line would raise an exception, resulting in an error but no harm to the application or its data. It’s best not to rely on that, though, so we’ve taken the extra step and added an extra layer of security. 

         With that, the core follow/unfollow functionality is complete, and any user can follow (or unfollow) any other user, which you should verify both by clicking around in the sample application and by running the test suite: 

$ bundle exec rspec spec/

 

 
 
 
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)