Parent

Included Modules

Files

Padrino::Generators::AdminPage

Defines the generator for creating a new admin page.

Attributes

default_orm[RW]

Public Class Methods

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 32
def create_controller
  self.destination_root = options[:root]
  if in_app_root?
    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/views/#{@orm.name_plural}")

      template "templates/page/controller.rb.tt",       destination_root("/admin/controllers/#{@orm.name_plural}.rb")
      template "templates/#{ext}/page/_form.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/_form.#{ext}")
      template "templates/#{ext}/page/edit.#{ext}.tt",  destination_root("/admin/views/#{@orm.name_plural}/edit.#{ext}")
      template "templates/#{ext}/page/index.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/index.#{ext}")
      template "templates/#{ext}/page/new.#{ext}.tt",   destination_root("/admin/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

[Validate]

Generated with the Darkfish Rdoc Generator 2.