Class: ActiveMailer::MigrationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/active_mailer/migration/migration_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/generators/active_mailer/migration/migration_generator.rb', line 14

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

.source_rootObject



10
11
12
# File 'lib/generators/active_mailer/migration/migration_generator.rb', line 10

def self.source_root
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#attributes_with_indexObject



26
27
28
# File 'lib/generators/active_mailer/migration/migration_generator.rb', line 26

def attributes_with_index
  attributes.select { |a| a.has_index? || (a.reference? && options[:indexes]) }
end

#create_migration_fileObject



22
23
24
# File 'lib/generators/active_mailer/migration/migration_generator.rb', line 22

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