Class: Padrino::Generators::AdminPage

### Home Classes Methods

### In Files

- lib/padrino-admin/generators/admin_page.rb

### Parent

Thor::Group

### Methods

- ::banner
- ::source_root
- #create_controller
- #source_paths

### Included Modules

- Thor::Actions
- Padrino::Generators::Actions
- Padrino::Generators::Admin::Actions

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Admin
- Padrino::Admin::AccessControl
- Padrino::Admin::AccessControl::Authorization
- Padrino::Admin::AccessControl::Base
- Padrino::Admin::AccessControl::ProjectModule
- Padrino::Admin::AccessControlError
- Padrino::Admin::Generators
- Padrino::Admin::Generators::Orm
- Padrino::Admin::Generators::OrmError
- Padrino::Admin::Helpers
- Padrino::Admin::Helpers::AuthenticationHelpers
- Padrino::Admin::Helpers::ViewHelpers
- Padrino::Generators
- Padrino::Generators::Admin
- Padrino::Generators::Admin::Actions
- Padrino::Generators::AdminApp
- Padrino::Generators::AdminPage

No matching classes.

# Padrino::Generators::AdminPage

Defines the generator for creating a new admin page.

### Attributes

default_orm[RW]

### Public Class Methods

banner() click to toggle source

Defines the "banner" text for the CLI.

    # File lib/padrino-admin/generators/admin_page.rb, line 15
    def self.banner; "padrino-gen admin_page [model]"; end

source_root() click to toggle source

Define the source template root.

    # File lib/padrino-admin/generators/admin_page.rb, line 13
    def self.source_root; File.expand_path(File.dirname(__FILE__)); end

### Public Instance Methods

create_controller() click to toggle source

Create controller for admin.

    # File lib/padrino-admin/generators/admin_page.rb, line 41
    def create_controller
      self.destination_root = options[:root]
      if in_app_root?
        @app_name = fetch_app_name
        @admin_name = options[:admin_name].classify
        @admin_path = options[:admin_name].underscore
        @admin_model = options[:admin_model]
        models.each do |model|
          @orm = default_orm || Padrino::Admin::Generators::Orm.new(model, adapter)
          self.behavior = :revoke if options[:destroy]
          empty_directory destination_root(@admin_path+"/views/#{@orm.name_plural}")

          template "templates/page/controller.rb.tt",       destination_root(@admin_path+"/controllers/#{@orm.name_plural}.rb")
          template "templates/#{ext}/page/_form.#{ext}.tt", destination_root(@admin_path+"/views/#{@orm.name_plural}/_form.#{ext}")
          template "templates/#{ext}/page/edit.#{ext}.tt",  destination_root(@admin_path+"/views/#{@orm.name_plural}/edit.#{ext}")
          template "templates/#{ext}/page/index.#{ext}.tt", destination_root(@admin_path+"/views/#{@orm.name_plural}/index.#{ext}")
          template "templates/#{ext}/page/new.#{ext}.tt",   destination_root(@admin_path+"/views/#{@orm.name_plural}/new.#{ext}")

          options[:destroy] ? remove_project_module(@orm.name_plural) : add_project_module(@orm.name_plural)
        end
      else
        say "You are not at the root of a Padrino application! (config/boot.rb not found)"
      end
    end

source_paths() click to toggle source

Look for custom template files in a generators folder under the project root.

    # File lib/padrino-admin/generators/admin_page.rb, line 23
    def source_paths
      if File.exist? destination_root('generators')
        ["#{destination_root('generators')}", File.expand_path(File.dirname(__FILE__))]
      else
        [File.expand_path(File.dirname(__FILE__))]
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.