Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2|
Lessons:- The Form HTML

produces the HTML


<label   for=  "user password"  > Password  </label><br />
<input   id=  "user password"   name=  " user[password]"   size= "30"   type=  "password"  />

 

As seen in Figure 7.13, text fields (type="text") simply display their contents, whereas password fields (type="password") obscure the input for security purposes, as seen in Figure 7.13. 

 

                 Figure 7.13 A filled-in form with text and password fields.

 

As we’ll see in Section 7.4, the key to creating a user is the special name attribute in each input:

<input id=  "user name"  name=  "user[name]" -  -  -  />
.
.
.

<input id=  "user password"   name=  "user[password]"  -  -  -  />

 

These name values allowRailsto construct an initialization hash (via the params variable) for creating users using the values entered by the user, as we’ll see in Section 7.3.

The second important element is the form tag itself. Rails creates the form tag using the @user object: because every Ruby object knows its own class (Section 4.4.1), Rails figures out that @user is of class User; moreover, since @user is a new user, Rails knows to construct a form with the post method, which is the proper verb for creating a new object (Box 3.2):  

 

<form  action=  "/users"  class= "new user"  id=  "new user"   method=  "post"  >

Here the class and id attributes are largely irrelevant; what’s important is action= "/users" and method="post". Together, these constitute instructions to issue an HTTP POST request to the /users URI. We’ll see in the next two sections what effects this has.

 

 
 
 
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)