(Quick Reference)

generate-controller

Purpose

Generates a controller and associated unit test for the given domain class

Examples

grails generate-controller
grails generate-controller org.bookstore.Book

Description

Grails supports a feature known as static scaffolding which involves the generation of a CRUD (Create/Read/Update/Delete) interface for a given domain class. Once generated, the controller and its views can be modified by you but they won't automatically update when you change the domain class.

The generate-controller command generates just the controller (and associated unit test) that implements CRUD for the given domain class. The argument is optional, but if you don't include it the command will ask you for the name of the domain class to scaffold. So for a domain class org.bookstore.Book, this command will generate the controller BookController.groovy in grails-app/controllers/org/bookstore.

Usage:

grails generate-controller [domain class name]

Fired Events:

  • StatusUpdate - When generation begins
  • StatusFinal - When generation completes