Class: Opinio::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Opinio::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/opinio/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_dependency_gem ⇒ Object
- #generate_initializer ⇒ Object
- #generate_migration ⇒ Object
- #generate_model ⇒ Object
- #generate_route ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/generators/opinio/install/install_generator.rb', line 29 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#add_dependency_gem ⇒ Object
25 26 27 |
# File 'lib/generators/opinio/install/install_generator.rb', line 25 def add_dependency_gem gem "kaminari" end |
#generate_initializer ⇒ Object
17 18 19 |
# File 'lib/generators/opinio/install/install_generator.rb', line 17 def generate_initializer template "initializers/opinio.erb", "config/initializers/opinio.rb" end |
#generate_migration ⇒ Object
13 14 15 |
# File 'lib/generators/opinio/install/install_generator.rb', line 13 def generate_migration migration_template "migrations/create_model.rb", "db/migrate/create_#{table_name}", {:assigns => {:name => name, :table_name => table_name}} end |
#generate_model ⇒ Object
9 10 11 |
# File 'lib/generators/opinio/install/install_generator.rb', line 9 def generate_model template "models/model.rb", "app/models/#{file_name}.rb" end |
#generate_route ⇒ Object
21 22 23 |
# File 'lib/generators/opinio/install/install_generator.rb', line 21 def generate_route route "opinio_model" end |