Sha256: 90f1a3adc4a7ef588c3a1ba46f1a412fe7d59ea962f7b50c5a952055e7594f68

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

require 'rails/generators/active_record/model/model_generator'
require 'generators/rails/base'

module ActiveRecord
  module Generators
    class ModelGenerator
      include Rails::Base

      def create_migration_file
        # return unless options[:migration] && options[:parent].nil?

        if options[:indexes] == false
          attributes.each { |attr| attr.attr_options.delete(:index) if attr.reference? && !attr.has_index? }
        end

        migration_template('../../migration/templates/create_table_migration.rb', "db/migrate/create_#{table_name}.rb")
      end

      def generate_locale_file
        invoke('locale:model', [name]) if configuration.autoload_model_generator_locale
      end

      def generate_test_file
        framework = configuration.test_framework

        return if framework.nil?
        invoke("#{framework}:model", [name]) rescue nil
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_generator-4.0.0 lib/generators/rails/model_generator.rb