lib/generators/translateable/migration_generator.rb in translateable-0.1.6 vs lib/generators/translateable/migration_generator.rb in translateable-0.1.7
- old
+ new
@@ -8,17 +8,20 @@
source_root File.expand_path('../templates', __FILE__)
argument :field_name, type: :string
argument :locale, type: :string, default: I18n.default_locale
+ # rubocop: disable Metrics/AbcSize
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
+ # rubocop: enable Metrics/AbcSize
private
def rails5?
Rails.version.start_with?('5')