Automatic Scaffold Controller

Posted by Anantha Narayanan On 10:39 PM No comments

By default if you are creating a controller using the following command:

grails create-controller org.example.DomainClass

Suppose your controller is based on an existing DomainClass, you might want to jump start using scaffolding.

You might be opening the controller file and commenting the code which Grails has created for you.

class DomainClassController {

  def index = { }

}
You might be adding the magic keyword that allows scaffolding later.

class DomainClassController {

  //def index = { }

  def scaffold = true

}
If you have many number of controllers to be created for prototyping and want to avoid this commenting and copy/paste activities use the following command:

grails create-scaffold-controller org.example.DomainClass

Grails will generate the controller with scaffold magic keyword by default.

Hope you like this tip (if you are a beginner of Grails and if you are cursing with prototyping for numerous controllers).

0 comments:

Post a Comment

Recommended Post Slide Out For Blogger