Class: Radmin::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_assetsObject



22
23
24
# File 'lib/generators/radmin/install_generator.rb', line 22

def copy_assets
  directory 'assets', 'public', :recursive => true
end

#copy_migrationsObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/radmin/install_generator.rb', line 9

def copy_migrations
  mig_dir = 'db/migrate'
  Dir[File.join(self.class.source_root,'migrations','*.rb')].sort!.each do |m|
    mig_name = File.basename(m).sub(/\.rb$/, '')
    new_name = mig_name.gsub(/^[0-9].*?_/, '')
    unless self.class.migration_exists?(mig_dir, new_name)
      mig_number = ActiveRecord::Generators::Base.next_migration_number(mig_dir)
      destination = File.join(mig_dir, "#{mig_number}_#{new_name}.rb")
      template("migrations/#{mig_name}.rb", destination)
    end
  end
end