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:- Changing the Layout Links

Unfortunately, if you actually examine the application in the browser, you’ll see that it doesn’t yet work. This is because the ‘‘remember me’’ functionality requires the user to have a remember token, but the current user doesn’t have one: We created the first user back in Section 7.4.3, long before implementing the callback that sets the remember token. To fix this, we need to save each user to invoke the before_save callback defined in Listing 8.18, which creates a remember token as a side effect:

 

Here we’veiterated over all the users in case you added morethan one while playing with the signup form. Note that we’ve passed an option to the save method; as currently written, save by itself wouldn’t work because we haven’t included the password or its confirmation. Indeed, for a real site we wouldn’t even know any of the passwords, but we would still want to be able to save the users. The solution is to pass validate: false to tell Active Record skip the validations (Rails API save).

                With that change, a signed-in user now sees the new links and dropdown menu defined by Listing 8.24, as shown in Figure 8.9.

      At this point, you should verify that you can sign in, close the browser, and then still be signed in when you visit the sample application. If you want, you can even inspect the browser cookies to see the result directly (Figure 8.10) .

 
 
 
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)