Class: Trivia::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Trivia::Generators::InstallGenerator
- 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_root ⇒ Object
11 12 13 |
# File 'lib/generators/trivia/install/install_generator.rb', line 11 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#add_acts_as_trivia_user ⇒ Object
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_migration ⇒ Object
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_models ⇒ Object
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 |