Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

To post your Question Join Classroom
Lesson Topics's No:-  |1 | 2|Last
Lessons:-Signin Form

Signin Form

With our tests in place, we’re ready to start developing the signin form. Recall from Listing 7.17 that the signup form uses the form_for helper, taking as an argument the user instance variable @user:


<%=   form for ( @userdo  |f|   %>
<%  end  %>


The main difference between this and the signin form is that we have no Session model, hence no analogue for the @user variable. This means that, in constructing the new session form, we have to give form_for slightly more information; in particular, whereas

form for( @user )


allows Rails to infer that the action of the form should be to POST to the URI /users, in the case of sessions we need to indicate the name of the resource and the corresponding URI: 

form for(: session, url: sessions path)


(A second option is to use form_tag in place of form_for; this might be more even idiomatically correct Rails, but it has less in common with the signup form, and at this stage I want to emphasize the parallel structure. Making a working form with form_tag is left as an exercise [Section 8.5].)

         With the proper form_for in hand, it’s easy to make a signin form to match the mockup in Figure 8.1 using the signup form (Listing 7.17) as a model, as shown in Listing 8.7.


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

  Students (0)