Rails generate memo
Rails generate memo.
rails generate
# List all the available generators
$ rails generate
The controller generator
# Usage: `rails generate controller NAME [action action] [options]`
# Help: `rails generate controller`
$ rails generate controller Users new
The model generator
# Usage: `rails generate model NAME [field[:type][:index] field[:type][:index]] [options]`
# Help: `rails generate model`
$ rails generate model User name:string email:string
The migration generator
# Usage: `rails generate model NAME [field[:type][:index] field[:type][:index]] [options]`
# Help: `rails generate migration`
# Add an index on the email column of the users table.
$ rails generate migration add_index_to_users_email
The resource generator
- Stubs out a new resource including:
- an empty model
- controller suitable for a restful, resource-oriented application
# Usage: `rails generate resource NAME [field[:type][:index] field[:type][:index]] [options]`
# Help: `rails generate resource`
$ rails generate resource post title:string body:text published:boolean
The scaffold generator
- Generates a full set of:
- model
- database migration for that model
- controller to manipulate it
- views to view and manipulate the data
- a test suite for each of the above
# Usage: `rails generate scaffold NAME [field[:type][:index] field[:type][:index]] [options]`
# Help: `rails generate scaffold`
$ rails generate scaffold post title body:text published:boolean