Ruby On Rails Classroom image

prateek  darmwal / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  |1 | 2 | 3 | 4 | 5|Last
Lessons:- The destroy Action

  The destroy Action

The final step needed to complete the Users resource is to add delete links and a destroy action. We’ll start by adding a delete link for each user on the user index page, restricting access to administrative users.

          To write tests for the delete functionality, it’s helpful to be able to have a factory to create admins. We can accomplish this by adding an :admin block to our factories, as shown in Listing 9.43.

 

With the code in Listing 9.43, we can now use FactoryGirl.create(:admin) to create an administrative user in our tests.

              Our security model requires that ordinary users not see delete links:

it { should not have link ( 'delete' ) }

 

  But administrative users should see such links, and by clicking on a delete link we expect an admin to delete the user, i.e., to change the User count by -1:

 

 

 

 
 
 
image
prateek  darmwal

Skills    Ruby On Rails

Qualifications :- High School - S.K.M. Sn. Sec. School, Haldwani, College/University - Graphic Era Hill University, Bhimtal,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:- I like to explore new technologies. I have skills in ruby on rails, php5, cakephp, jquery, javascript, html/css, java, c & c++. I love coding
Explore
 

  Students (0)