Class: ActiveAdmin::Generators::InstallGenerator

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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) source_root



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

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

Instance Method Details

- (Object) copy_initializer



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

def copy_initializer
  @underscored_user_name = name.underscore
  template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
end

- (Object) create_assets



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

def create_assets
  generate "active_admin:assets"
end

- (Object) create_migrations



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

def create_migrations
  migration_template 'migrations/create_active_admin_comments.rb', 'db/migrate/create_active_admin_comments.rb'
end

- (Object) setup_directory



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

def setup_directory
  empty_directory "app/admin"
  template 'dashboard.rb', 'app/admin/dashboard.rb'
  if options[:users].present?
    @user_class = name
    template 'admin_user.rb.erb', "app/admin/#{name.underscore}.rb"
  end
end

- (Object) setup_routes



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

def setup_routes
  if ARGV.include? "--skip-users"
    route "ActiveAdmin.routes(self)"
  else # Ensure Active Admin routes occur after Devise routes so that Devise has higher priority
    inject_into_file "config/routes.rb", "\n  ActiveAdmin.routes(self)", after: /devise_for .*, ActiveAdmin::Devise\.config/
  end
end