Rails generate commands

suggest change

Versions

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents