Class: HabtmGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/habtm/habtm_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



8
9
10
11
12
13
14
15
# File 'lib/generators/habtm/habtm_generator.rb', line 8

def create_migration_file
  models.map!{|i|i.singularize}
  migration_template "habtm_migration.rb.erb",
    "db/migrate/#{migration_name}.rb"

  add_migration_line model: models[0],  other: models[1]
  add_migration_line model: models[1],  other: models[0]
end