Rails generate commands
suggest changeVersions
Rails 5.0
Introduction
Usage: rails generate GENERATOR_NAME [args] [options].
Use rails generate to list available generators. Alias: rails g.
Parameters
| Parameter | Details |
|---|---|
-h / --help |
Help for a generator |
-p / --pretend |
Run the generator without writing files |
field:type |
Column name, then one of the types in Remarks |
Remarks
Common values for type in field:type. The generator also accepts :references, :bigint, :json, and :timestamp.
| Data type | Description |
|---|---|
:string |
Short text. The usual database limit is 255 characters. |
:text |
Longer text |
:binary |
Raw bytes, such as a small file stored in the database |
:boolean |
True or false |
:date |
A date, with no time |
:time |
A time, with no date |
:datetime |
Date and time |
:float |
Approximate floating-point number |
:decimal |
Exact decimal number. Pass :precision and :scale when you need them. |
:integer |
Whole number |
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents