Class: ActiveAdmin::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/active_admin/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



14
15
16
# File 'lib/generators/active_admin/install/install_generator.rb', line 14

def self.next_migration_number(dirname)
  Time.now.strftime("%Y%m%d%H%M%S")
end

.source_rootObject



10
11
12
# File 'lib/generators/active_admin/install/install_generator.rb', line 10

def self.source_root
  @_active_admin_source_root ||= File.expand_path("../templates", __FILE__)
end

Instance Method Details

#copy_assetsObject



31
32
33
34
35
# File 'lib/generators/active_admin/install/install_generator.rb', line 31

def copy_assets
  template 'active_admin_vendor.js',  'public/javascripts/active_admin_vendor.js'
  template 'active_admin.js',         'public/javascripts/active_admin.js'
  directory 'images', 'public/images/active_admin'
end

#copy_initializerObject



18
19
20
# File 'lib/generators/active_admin/install/install_generator.rb', line 18

def copy_initializer
  template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
end

#create_migrationsObject



37
38
39
40
41
42
43
# File 'lib/generators/active_admin/install/install_generator.rb', line 37

def create_migrations
  Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
    name = File.basename(filepath)
    migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
    sleep 1
  end
end

#setup_directoryObject



22
23
24
25
# File 'lib/generators/active_admin/install/install_generator.rb', line 22

def setup_directory
  empty_directory "app/admin"
  template 'dashboards.rb', 'app/admin/dashboards.rb'
end

#setup_routesObject



27
28
29
# File 'lib/generators/active_admin/install/install_generator.rb', line 27

def setup_routes
  route "ActiveAdmin.routes(self)"
end