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:- Friendly Forwarding

To implement the forwarding itself, we use the redirect_back_or method to redirect to the requested URI if it exists, or some default URI otherwise, which we add to the Sessions controller create action to redirect after successful signin (Listing 9.20). The redirect_back_or method uses the or operator || through

session [:return to] ||  default

 

This evaluates to session[:return_to] unless it’s nil, in which case it evaluates to the given default URI. Note that Listing 9.18 is careful to remove the forwarding URI; otherwise, subsequent signin attempts would forward to the protected page until the user closed his browser. (Testing for this is left as an exercise [Section 9.6.])  

With that, the friendly forwarding integration test in Listing 9.17 should pass, and the basic user authentication and page protection implementation is complete. As usual, it’s a good idea to verify that the test suite is green before proceeding:

$ 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)