Class

Rails::Generator::NamedBase

Inheritance
< Rails::Generator::Base < Object

The base generator for named components: models, controllers, mailers, etc. The target name is taken as the first argument and inflected to singular, plural, class, file, and table forms for your convenience. The remaining arguments are aliased to actions as an array for controller and mailer convenience.

Several useful local variables and methods are populated in the initialize method. See below for a list of Attributes and External Aliases available to both the manifest and to all templates.

If no name is provided, the generator raises a usage error with content optionally read from the USAGE file in the generator‘s base path.

For example, the controller generator takes the first argument as the name of the class and subsequent arguments as the names of actions to be generated:

  ./script/generate controller Article index new create

See Rails::Generator::Base for a discussion of manifests, Rails::Generator::Commands::Create for methods available to the manifest, and Rails::Generator for a general discussion of generators.

Attributes

Name Visibility R/W Description
class_name public R
class_nesting public R
class_nesting_depth public R
class_path public R
file_path public R
name public R
plural_name public R
singular_name public R
table_name public R

Aliases

Method Alias Description
args → actions
singular_name → file_name

Methods

Class

Visibility Signature
public new (runtime_args, runtime_options = {})

Instance

Visibility Signature
protected attributes ()
protected banner ()

Class Method Detail

new(runtime_args, runtime_options = {})

Instance Method Detail

attributes()

banner()

Override with your own usage banner.