LinuxCommandLibrary

rails-generate

Scaffold Rails application components from templates

TLDR

Generate model

$ rails generate model [Name] [field:type]
copy
Generate controller
$ rails generate controller [Name] [action]
copy
Generate scaffold
$ rails generate scaffold [Name] [field:type]
copy
Generate migration
$ rails generate migration [Name]
copy

SYNOPSIS

rails generate generator name [options]

DESCRIPTION

rails generate creates boilerplate files from templates for common Rails application components. It scaffolds models with database migrations, controllers with associated views and routes, and full CRUD interfaces through the scaffold generator, following Rails naming conventions and directory structure automatically.
Each generator produces the appropriate set of files including source code, test stubs, and configuration entries. The --pretend flag previews what would be created without writing files, and --skip-routes prevents automatic route additions. Custom generators can be created to match project-specific patterns, and the inverse operation rails destroy removes all files a generator created.

PARAMETERS

model name

Generate model.
controller name
Generate controller.
scaffold name
Generate full CRUD.
migration name
Generate migration.
-p, --pretend
Preview without creating.
--skip-routes
Don't add routes.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community