Sha256: 674bc7e1ed0e45a5c4e36cd8ab5526809fff62a0e6cb0c90f1603870e35fb553

Contents?: true

Size: 954 Bytes

Versions: 5

Compression:

Stored size: 954 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 do |attr|
            attr.attr_options.delete(:index) if attr.reference? && !attr.has_index?
          end
        end

        path = "db/migrate/create_#{table_name}.rb"

        migration_template('../../migration/templates/create_table_migration.rb', path)
      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

5 entries across 5 versions & 1 rubygems

Version Path
active_generator-4.0.6 lib/generators/rails/model_generator.rb
active_generator-4.0.5 lib/generators/rails/model_generator.rb
active_generator-4.0.4 lib/generators/rails/model_generator.rb
active_generator-4.0.3 lib/generators/rails/model_generator.rb
active_generator-4.0.2 lib/generators/rails/model_generator.rb