Sha256: 8482469cd584d4109d95b8ff471e9e7daab0a147e9c2234cfd6e79e67a686ea2

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

require 'rails/generators'

module TranslatableRecords
  module Generators
    class TranslationGenerator < Rails::Generators::NamedBase
      include Rails::Generators::Migration

      source_root File.expand_path('../templates', __FILE__)

      def create_model_file
        template 'model.rb', "app/models/#{singular_table_name}_translation.rb"
      end

      def create_migration_file
        @attributes = class_name.constantize.translations
        migration_template 'migration.rb', "db/migrate/create_#{singular_table_name}_translations.rb"
      end

      def self.next_migration_number(path)
        Time.now.utc.strftime '%Y%m%d%H%M%S'
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
translatable_records-5.1.0 lib/generators/translation/translation_generator.rb
translatable_records-4.0.0.1 lib/generators/translation/translation_generator.rb