10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/generators/chapter11_1/solutions/solutions_generator.rb', line 10
def add_migration
found_candidate = Dir.glob(File.join(Rails.root,'db','migrate','*create_micropost*')).present?
if (found_candidate &&
yes?("We found a migration file containing the word '_admin_'. We think you have the correct migration. Do you still way to copy the solution anyway? (yes/no)", :yellow)) \
or !found_candidate
src = File.expand_path("../snippets/migration_create_microposts.rb", __FILE__)
dest = File.join(Rails.root,'db','migrate',Time.now.strftime("%Y%m%d%H%M%S")+'_create_microposts.rb')
copy_file(src,dest)
end
end
|