Sha256: 06d4f837e0be4e3e1ba74414080e7855bde60c859f3512d1ff6296771419bca2

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

require 'rails/generators/active_record'

module I18n
  module ActiveRecord
    module Generators
      class  InstallGenerator < ::ActiveRecord::Generators::Base
        desc "Installs i18n-active_record and generates the necessary migrations"

        argument :name, type: :string, default: 'Translation'

        class_option :simple, type: :boolean, default: false, desc: 'Perform the simple setup'

        source_root File.expand_path('templates', __dir__)

        def copy_initializer
          tpl = "#{options[:simple] ? 'simple' : 'advanced'}_initializer.rb.erb"

          template tpl, 'config/initializers/i18n_active_record.rb'
        end

        def create_migrations
          migration_template 'migration.rb.erb', "db/migrate/create_#{table_name}.rb"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n-active_record-0.4.1 lib/generators/i18n/active_record/install_generator.rb
i18n-active_record-0.4.0 lib/generators/i18n/active_record/install_generator.rb