Improve this page

Generators

Built-in Generators

$ buffalo generate -h
A collection of generators to make life easier

Usage:
  buffalo generate [command]

Aliases:
  generate, g

Available Commands:
  action      Generates new action(s)
  docker      Generates a Dockerfile
  mailer      Generates a new mailer for Buffalo
  resource    Generates a new actions/resource file
  task        Generates a grift task

Flags:
  -h, --help   help for generate

Use "buffalo generate [command] --help" for more information about a command.

See also /docs/db#generators for a list of database related generators.

Generating Actions

$ buffalo g action --help

Generates new action(s)

Usage:
  buffalo generate action [name] [actionName...] [flags]

Aliases:
  action, a, actions
$ buffalo g a users show index create

--> templates/users/show.html
--> templates/users/index.html
--> templates/users/create.html
--> actions/users.go
--> actions/users_test.go
--> goimports -w .

In some cases you will need to generate an action with an HTTP method different than GET, for that case you can use the --method flag, like in the following example:

$ buffalo g actions users message --method POST

In some other scenarios you will need to generate an action without generating an HTML template. To skip the generation of the HTML template for creating an action you can pass the --skip-template flag to the generator, i.e:

$ buffalo g actions users update --skip-template

Destroying Actions

You can remove files generated by this generator by running:

$ buffalo destroy action users

Or in short form:

$ buffalo d a users