

This code is generated by the scaffold generator.

Let's look at the code behind the controller. It generates auto-files as shown below − The Controller So now, let's start once again to generate Scaffold code manually by using the scaffold helper script − By running scaffold as a script, we can get all the code written to disk, where we can investigate it and then start tailoring it to our requirements. With the scaffold action, Rails generates all the code it needs dynamically. This application uses the same database for each. Rails lets you run in the development mode, test mode, or production mode, using different databases.

When you finish, it should look as follows − To instruct Rails how to find the database, edit the configuration file cookbook\config\database.yml and change the database name to cookbook. Mysql> grant all privileges on cookbook.* So, run the following command to create a complete directory structure. Open a command window and navigate to where you want to create this cookbook web application. To understand scaffolding, let's create a database called cookbook and a table called recipes. You can use scaffolding as a foundation to jump start your development. You can learn how Rails works by looking at the generated code. You can quickly get code in front of your users for feedback. Scaffolding provides more than cheap demo thrills. While you're developing Rails applications, especially those which are mainly providing you with a simple interface to data in a database, it can often be useful to use the scaffold method.
