Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

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

The only real novelty in Listing 9.9 is the reload method, which appears in the test for changing the user’s attributes:

specify { user.reload.name.should == new name }
specify { user.reload.email.should == new email }

 

This reloads the user variable from the test database using user.reload, then verifies that the user’s new name and email match the new values. The update action needed to get the tests in Listing 9.9 to pass is similar to the final form of the create action (Listing 8.27), as seen in Listing 9.10. All this does is add

flash [:success] =  "Profile updated"
sign in  @user
redirect to  @user

 

to the code in Listing 9.8. Note that we sign in the user as part of a successful profile update; this is because the remember token gets reset when the user is saved (Listing 8.18), which invalidates the user’s session (Listing 8.22). This is a nice security feature, because it means that any hijacked sessions will automatically expire when the user information is changed.

 

 

Note that, as currently constructed, every edit requires the user to reconfirm the password (as implied by the empty confirmation text box in Figure 9.2), which is a minor annoyance but makes updates much more secure.

        With the code in this section, the user edit page should be working, as you can double-check by re-running the test suite, which should now be green:

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