Ruby on Rails - The Generators


Ruby provides a script called Generator. This script can be used to generate many useful items in Rails. Most important generators are listed below.

Generator Description
script/generate model ModellName Generates Active Records.
script/generate controller ListController show edit Generates Controller.
script/generate scaffold ModelName ControllerName Generates Scaffold.
script/generate migration AddNewTable Generates Table to migrate.
script/generate plugin PluginName Generates Plugin.
script/generate integration_test TestName Generates Integ Test.
script/generate session_migration Generates Session Migration.

Following is the list of options, which can be used along with generators:

  • -p, --pretend Run but do not make any changes.

  • -f, --force Overwrite files that already exist.

  • -s, --skip Skip files that already exist.

  • -q, --quite Suppress normal output.

  • -t, --backtrace Debugging: show backtrace on errors.

  • -h, --help Show this help message.

  • -c, --svn Modify files with subversion.

Check following link for more information on Rails Generators.