Stats

74 Contributors: 14 Monday, July 17, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Rails generate commands

Introduction

Usage: rails generate GENERATOR_NAME [args] [options].

Use rails generate to list available generators. Alias: rails g.

Parameters

ParameterDetails
-h/--helpGet help on any generator command
-p/--pretendPretend Mode: Run generator but will not create or change any files
field:type'field-name' is the name of the column to be created and 'type' is the data-type of column. The possible values for 'type' in field:type are given in the Remarks section.

Remarks

The possible values for 'type' in field:type are:

Data TypeDescription
:stringFor smaller pieces of text (usually has a character limit of 255)
:textFor longer pieces of text, like a paragraph
:binaryStoring data including images, audios and videos
:booleanStoring true or false values
:dateOnly the date
:timeOnly the time
:datetimeDate and time
:floatStoring floats without precision
:decimalStoring floats with precision
:integerStoring whole numbers

Related Examples