Class: Translateable::MigrationGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/translateable/migration_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject

rubocop: disable Metrics/AbcSize

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
# File 'lib/generators/translateable/migration_generator.rb', line 14

def create_migration_file
  raise ArgumentError, "given locale #{locale} is not available, check I18n.available_locales" unless I18n.available_locales.include?(locale.to_sym)
  migration_template('migration.rb.erb', "db/migrate/migrate_translateable_#{name}_#{field_name}.rb",
                     migration_version: migration_version,
                     table_name: name,
                     field_name: field_name,
                     field_type: name.classify.constantize.columns_hash[field_name].type,
                     locale: locale)
end