Class: Ckeditor::MigrationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/ckeditor/migration/migration_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



17
18
19
# File 'lib/generators/ckeditor/migration/migration_generator.rb', line 17

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

.source_rootObject



13
14
15
# File 'lib/generators/ckeditor/migration/migration_generator.rb', line 13

def self.source_root
  @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates', 'models/'))
end

Instance Method Details

#create_migrationObject



32
33
34
# File 'lib/generators/ckeditor/migration/migration_generator.rb', line 32

def create_migration
  migration_template "#{generator_dir}/migration.rb", File.join('db/migrate', "create_ckeditor_assets.rb")
end

#create_modelsObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/ckeditor/migration/migration_generator.rb', line 21

def create_models
  template "#{generator_dir}/asset.rb",
           File.join('app/models', ckeditor_dir, "asset.rb")
  
  template "#{generator_dir}/picture.rb",
           File.join('app/models', ckeditor_dir, "picture.rb")
  
  template "#{generator_dir}/attachment_file.rb",
           File.join('app/models', ckeditor_dir, "attachment_file.rb")
end