Rails scaffold can create the models, views, and controllers for a new resource in a single operation.
Scaffold Would create a full CRUD (create, read, update, delete) for a table.
Scaffold auto generate all the codes that rails needs. Later we can alter the code based on our requirements.
Lets generate a scaffold using the scaffold helper script given below :
rails generate scaffold user name:string address:string
After this we can see that all the major parts like model, view , controller etc.So we can call:
rake db:migrate
Now start the server:
Rails s
Now, open a browser and navigate to "http://localhost:3000/users/new". This will provide you a screen to create new entries in the Users table.
Once you click the Create button , your record is added into the users table.
To see the saved record navigate to "http://localhost:3000/users/1 ".
You will see edit, show, and destroy options on this page.
0 Comment(s)