Creating a CRUD Application
Next, we will create a CRUD application with the scaffold generator. The scaffold generator generates all the required model and controller scripts and the RHTML view templates for an interface to data in a database table. Select Run>External Tools>Create Scaffold to create a scaffolding for the database table
catalogs. Specify a model name,
catalog, for example, and a controller name,
catalog, in the Variable Input frames. A scaffolding, which consists of a model class,
catalog.rb; a controller class,
catalog_controller.rb; and view templates,
new.rhtml, gets created in the Rails application. Start the WEBrick server with Run>External Tools>Start WEBrick server.
Figure 12. Starting WEBrick server
Access the WEBrick server with the URL
Figure 13. Rails index.html page
The catalog entries listing can be displayed with the list controller action. Invoke the controller action list with the URL http://localhost:3000/catalog/list.
Figure 14. Catalog listings
Next, we'll discuss the RadRails plugin.
Installing the RadRails plugin requires the RDT plugin to be installed. Therefore, if you have not installed the RDT plugin, as explained in the previous section, do so now. To install the RadRails plugin, select Help>Software Updates>Find and Install. Select "Search for new features to install" in the Feature Updates frame and click on Next. Click on the New Remote Site button in the "Update sites to visit" frame. Specify a update site name--RadRails, for example--and specify the URL http://radrails.sourceforge.net/update in the URL field. Click the OK button. Select the RadRails update site configuration and click on Finish. Select the features to install and click on Next. Accept the feature license and click on Next. In the Installation frame, click on the Finish button. Select "Install All" in the Feature Verification frame. Restart Eclipse for the plugin configuration to take effect. In the Eclipse IDE, open the RadRails perspective by selecting Window>Open Perspective>Other>Rails.
Figure 15. Opening the Rails perspective
The RadRails perspective includes the following views: Servers, Generators, Rake Tasks, Console, RI, and Rails Plugins. The Servers view consists of WEBrick server configurations for the Rails applications. The Generators view consists of generators for model, controller, scaffold, and migration scripts. The Rake Tasks view is still in development and consists of rake tasks such as