Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Superclass: Object

Class deprecated or moved

This class is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

The base code generator is bare-bones. It sets up the source and destination paths and tells the logger whether to keep its trap shut.

It’s useful for copying files such as stylesheets, images, or javascripts.

For more comprehensive template-based passive code generation with arguments, you’ll want Rails::Generator::NamedBase.

Generators create a manifest of the actions they perform then hand the manifest to a command which replays the actions to do the heavy lifting (such as checking for existing files or creating directories if needed). Create, destroy, and list commands are included. Since a single manifest may be used by any command, creating new generators is as simple as writing some code templates and declaring what you’d like to do with them.

The manifest method must be implemented by subclasses, returning a Rails::Generator::Manifest. The record method is provided as a convenience for manifest creation. Example:

  class StylesheetGenerator < Rails::Generator::Base
    def manifest
      record do |m|
        m.file('application.css', 'public/stylesheets/application.css')

See Rails::Generator::Commands::Create for a list of methods available to the manifest.

Show files where this class is defined (1 file)
Register or log in to add new notes.