Sha256: 46ffa794f6334fde577c84870250a8f5ebca026da6b7f0924d3bd4436bc2d133
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
module Chapter10 module Generators class SolutionsGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) def copy_app_tree directory(self.class.source_root, Rails.root) end def add_destroy_action_to_users_resource dest = File.join(Rails.root,'config','routes.rb') insert_into_file(dest, :after => %r{:index,\s*:show}) do ", :destroy" end end def add_migration found_candidate = Dir.glob(File.join(Rails.root,'db','migrate','*_admin_*')).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_add_admin_to_users.rb", __FILE__) dest = File.join(Rails.root,'db','migrate',Time.now.strftime("%Y%m%d%H%M%S")+'_add_admin_to_users.rb') copy_file(src,dest) end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems