Class: Hayfork::Generators::RebuildGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Includes:
CreateOrReplaceMigrationConcern
Defined in:
lib/generators/hayfork/rebuild_generator.rb

Instance Method Summary collapse

Methods included from CreateOrReplaceMigrationConcern

#create_migration

Instance Method Details

#copy_migrationObject



33
34
35
# File 'lib/generators/hayfork/rebuild_generator.rb', line 33

def copy_migration
  migration_template "migrations/rebuild.rb", "#{db_migrate_path}/rebuild_#{table_name}.rb", migration_version: migration_version
end

#migration_versionObject



42
43
44
45
# File 'lib/generators/hayfork/rebuild_generator.rb', line 42

def migration_version
  return unless Rails::VERSION::MAJOR >= 5
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end

#table_nameObject



37
38
39
40
# File 'lib/generators/hayfork/rebuild_generator.rb', line 37

def table_name
  return "haystack" if class_name == "Haystack"
  super
end