class Base

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

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.directory('public/stylesheets')
      m.file('application.css', 'public/stylesheets/application.css')
    end
  end
end

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

Inherits from

Object

Includes

Attributes

Methods (defined here)

Used by

Subclasses (2)

Methods (inherited)

From Object (32)
From Rails::Generator::Options (11)
From ActionController::Caching (3)
From ActionController::Cookies (2)
From ActionController::Flash (1)
From ActionController::HttpAuthentication::Basic::ControllerMethods (3)
From ActionController::RecordIdentifier (5)
From ActionController::RequestForgeryProtection (8)
From ActionController::Rescue (7)
From ActionController::Streaming (2)
From ActionController::Translation (4)
From ActiveRecord::Callbacks (14)
From ActiveRecord::Dirty (4)
From ActiveRecord::Locking::Pessimistic (1)
From ActiveRecord::NamedScope (1)
From ActiveRecord::Serialization (5)
From ActiveRecord::Transactions (4)
From ActiveRecord::Validations (7)
From Benchmark (1)
From ActionController::Components::InstanceMethods (2)
From ActiveRecord::Locking::Optimistic::ClassMethods (7)
From ActiveRecord::NamedScope::ClassMethods (2)
From ActiveRecord::Serialization::ClassMethods (1)
From ActiveRecord::Validations::ClassMethods (13)
From ActiveSupport::Memoizable (1)

Type at least 2 characters to search.

↑↓ navigate · open · esc close