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:- Access Control

To avoid code repetition, you should also remove signed_in_user from the Users controller at this time.

            With the code in Listing 10.27, the signed_in_user method is now available in the Microposts controller, which means that we can restrict access to the create and destroy actions with the before filter shown in Listing 10.28. (Since we didn’t generate it at the command line, you will have to create the Microposts controller file by hand.)

 

 

Note that we haven’t restricted the actions the before filter applies to since it applies to them both by default. If we were to add, say, an index action accessible even to non-signed-in users, we would need to specify the protected actions explicitly:

 

 

At this point, the tests should pass:

$ bundle exec rspec spec/requests/authentication pages spec.rb

 

 

 
 
 
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)