Class: Trivia::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/trivia/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



15
16
17
# File 'lib/generators/trivia/install/install_generator.rb', line 15

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

.source_rootObject



11
12
13
# File 'lib/generators/trivia/install/install_generator.rb', line 11

def self.source_root
  @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

Instance Method Details

#add_acts_as_trivia_userObject



27
28
29
# File 'lib/generators/trivia/install/install_generator.rb', line 27

def add_acts_as_trivia_user
  say "Please add 'acts_as_trivia_user' to your User model", :green
end

#generate_migrationObject



19
20
21
# File 'lib/generators/trivia/install/install_generator.rb', line 19

def generate_migration
  migration_template 'db/migrate/create_trivia_tables.rb', 'db/migrate/create_trivia_tables.rb'
end

#generate_modelsObject



23
24
25
# File 'lib/generators/trivia/install/install_generator.rb', line 23

def generate_models
  ['answer.rb', 'chosen_answer.rb', 'question.rb'].map { |f| "app/models/#{f}" }.each { |f| template f, f }
end