22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/generators/uniq_identifier/add_generator.rb', line 22
def add_migration_file
migration_template 'migration.rb', "db/migrate/add_uuid_#{file_path}.rb" if options.orm == :active_record
hook = 'uniq_identifier'
data = "\n"
data += indent("#{hook}")
if options.orm == 'mongoid'
data += "\n"
data += indent("field :uuid, type: String")
end
if options.orm == :active_record
= "class #{class_name} < ActiveRecord::Base"
else
= 'include Mongoid::Document'
end
model_path = File.join('app', 'models', "#{file_path}.rb")
inject_into_file model_path, data, after: , verbose: true
readme("./README-#{options.orm}")
end
|