Class: BlogGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration, Thor::Actions
Defined in:
lib/generators/blog_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



24
25
26
# File 'lib/generators/blog_generator.rb', line 24

def self.next_migration_number(dirname)
  ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#generate_migrationObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/blog_generator.rb', line 8

def generate_migration
  destination   = File.expand_path('db/migrate/01_create_sofa_blog.rb', self.destination_root)
  migration_dir = File.dirname(destination)
  destination   = self.class.migration_exists?(migration_dir, 'create_sofa_blog')

  if destination
    puts "\e[0m\e[31mFound existing create_sofa_blog.rb migration. Remove it if you want to regenerate.\e[0m"
  else
    migration_template 'db/migrate/01_create_sofa_blog.rb', 'db/migrate/create_sofa_blog.rb'
  end
end

#show_readmeObject



20
21
22
# File 'lib/generators/blog_generator.rb', line 20

def show_readme
  readme 'lib/generators/README'
end