The Rails generator system is a simple but powerful way to create a family of files from a set of templates based on user commands. The Rails core defines generators for controllers, models, mailers, integration tests, plugins, scaffolds, and a couple of other things. In addition to supporting more complex plugins, generators can stand on their own to automate repetitive tasks. Examples might include custom scaffolding for controllers and models, standard layout templates, or test suites.
Generators are called via the script/generate command. The general format is as follows:
$ruby script/generate generator_name arg1 arg2 --opt1 --opt2
Every generator responds to a set of common option flags, which are described in the following table.
|-c --svn||Add new files to subversion, if available.|
|-h --help||Show the help message.|
|-f --force||Overwrite existing files without asking.|
|-p --pretend||Show the list of files that would be created, but don't actually create any files.|
|-q --quiet||No output.|
|-s --skip||Skip existing files without asking.|
|-t --backtrace||Show a stack trace on error.|
|-v --verbose||Verbose output.|
The arguments and options are parsed for you in the parent generator class before your generator is initialized. You have the ability to add new option arguments to your generator.
Generators come in two flavors: basic and named. In a basic generator, the arguments are placed in the instance variable args, and command-line ...