Class: Padrino::Generators::Model

### Home Classes Methods

### In Files

- lib/padrino-gen/generators/model.rb

### Parent

Thor::Group

### Methods

- ::banner
- ::source_root
- #create_model

### Included Modules

- Thor::Actions
- Padrino::Generators::Actions
- Padrino::Generators::Components::Actions

### Files

- README.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Generators
- Padrino::Generators::Actions
- Padrino::Generators::Actions::ClassMethods
- Padrino::Generators::App
- Padrino::Generators::AppRootNotFound
- Padrino::Generators::Cli
- Padrino::Generators::Component
- Padrino::Generators::Components
- Padrino::Generators::Components::Actions
- Padrino::Generators::Controller
- Padrino::Generators::Helper
- Padrino::Generators::Mailer
- Padrino::Generators::Migration
- Padrino::Generators::Model
- Padrino::Generators::Plugin
- Padrino::Generators::Project
- Padrino::Generators::Runner
- Padrino::Generators::SqlHelpers
- Padrino::Generators::Task
- ActiveRecord
- ActiveRecord::Schema
- Object

No matching classes.

# Padrino::Generators::Model

Responsible for generating new models for the specified ORM component.

### Public Class Methods

banner() click to toggle source

    # File lib/padrino-gen/generators/model.rb, line 10
    def self.banner; "padrino-gen model [name] [fields]"; end

source_root() click to toggle source

    # File lib/padrino-gen/generators/model.rb, line 9
    def self.source_root; File.expand_path(File.dirname(__FILE__)); end

### Public Instance Methods

create_model() click to toggle source

Execute the model generation.

    # File lib/padrino-gen/generators/model.rb, line 31
    def create_model
      app = options[:app]
      return unless valid_model_for?(app)

      include_component_module_for(:test)
      migration_name = "create_#{name.pluralize.underscore}"
      apply_default_fields fields
      create_model_file(name, :fields => fields, :app => app)
      generate_model_test(name) if test?
      create_model_migration(migration_name, name, fields) unless options[:skip_migration]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.