Ruby On Rails Classroom image

Anil  Bist / Professional / 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
Anil  Bist

Skills    Ruby On Rails

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)