Sha256: 506c6860fc0b63871739228463b1dd21f4e9f598350ab2b6901d42a14841e7ef
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
require 'rails/generators/active_record' module ActiveAdmin module Generators class InstallGenerator < ActiveRecord::Generators::Base desc "Installs Active Admin and generates the necessary migrations" argument :name, :type => :string, :default => "AdminUser" hook_for :users, :default => "devise", :desc => "Admin user generator to run. Skip with --skip-users" def self.source_root @_active_admin_source_root ||= File.expand_path("../templates", __FILE__) end def copy_initializer @underscored_user_name = name.underscore template 'active_admin.rb.erb', 'config/initializers/active_admin.rb' end 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 def setup_routes route "ActiveAdmin.routes(self)" end def create_assets generate "active_admin:assets" end 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 end end end
Version data entries
4 entries across 4 versions & 1 rubygems