Generators for creating models

IntelliJ IDEA makes it possible to stub out models using the Rails generators:

The model generator creates a model class that defines a database table, and a migration that defines columns within the table. Besides that, a unit test and a test fixture are created.

The scaffold generator creates a model class that defines a database table, and a migration that defines columns within the table. Besides that, a controller, forms and the other necessary resources are created.

To create a model

Do one of the following:

Choose New on the context menu of an editor or Project tool window, or press Alt+Insert, and then choose New - Run Rails Generator.

Run Rails generator: choose Tools | Run Rails Generator.

With a Model Dependency diagram having the focus, choose New - Model on the context menu of the diagram background, or press Alt+Insert.

In the dialog box that opens, start typing the generator name, for example, model or scaffold.

Note that for creating models in diagram, only model generator is used.

Type the name of a model to be created, in singular, and the list of fields and their types. Note that code completion is available for the field types.

A migration is created.

Create columns in the table. To do that, you have to run the migration in one of the following ways: