Class: SimpleLocalizer::Generators::CreateMigrationGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname, count = 0) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/simple_localizer/create_migration_generator.rb', line 10

def self.next_migration_number(dirname, count = 0)
  if count == 0
    name = Time.now.strftime("%Y%m%d%H%M%S")
  else
    name = (Time.now + count).strftime("%Y%m%d%H%M%S")
  end

  if Dir[File.join(dirname, name + '*')].empty?
    name
  else
    next_migration_number(dirname, count + 1)
  end
end

Instance Method Details

#create_migrationObject



24
25
26
27
28
29
# File 'lib/generators/simple_localizer/create_migration_generator.rb', line 24

def create_migration
  migration_template(
    "create_translations.rb",
    "db/migrate/create_#{model_name.underscore.gsub("/", "_")}_translations",
  )
end