Class: ActiveRecord::Generators::ModelGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/rails/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



7
8
9
10
11
# File 'lib/generators/rails/model_generator.rb', line 7

def create_migration_file
  # return unless options[:migration] && options[:parent].nil?
  attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false
  migration_template "../../migration/templates/create_table_migration.rb", "db/migrate/create_#{table_name}.rb"
end

#generate_locale_fileObject



13
14
15
# File 'lib/generators/rails/model_generator.rb', line 13

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

#generate_test_fileObject



17
18
19
20
21
# File 'lib/generators/rails/model_generator.rb', line 17

def generate_test_file
  unless ActiveGenerator.configuration.test_framework.nil?
    invoke("#{ActiveGenerator.configuration.test_framework}:model", [name]) rescue nil
  end
end