Class: ActiveAdmin::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



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

def copy_initializer
  @underscored_user_name = name.underscore
  @use_authentication_method = options[:users].present?
  template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
end

#create_assetsObject



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

def create_assets
  generate "active_admin:assets"
end

#create_migrationsObject



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

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

#setup_directoryObject



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

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

#setup_routesObject



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

def setup_routes
  if options[:users] # 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/
  else
    route "ActiveAdmin.routes(self)"
  end
end