Ruby On Rails Classroom image

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