Class: Kudos::Generators::ActiveRecordGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Kudos::Generators::ActiveRecordGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/kudos/active_record_generator.rb
Class Method Summary collapse
- .migration_version ⇒ Object
- .next_migration_number(dirname) ⇒ Object
- .requires_migration_number? ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.migration_version ⇒ Object
19 20 21 |
# File 'lib/generators/kudos/active_record_generator.rb', line 19 def self.migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if requires_migration_number? end |
.next_migration_number(dirname) ⇒ Object
15 16 17 |
# File 'lib/generators/kudos/active_record_generator.rb', line 15 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end |
.requires_migration_number? ⇒ Boolean
23 24 25 |
# File 'lib/generators/kudos/active_record_generator.rb', line 23 def self.requires_migration_number? Rails::VERSION::MAJOR.to_i >= 6 end |
Instance Method Details
#create_migration_file ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/kudos/active_record_generator.rb', line 27 def create_migration_file @user_model_name = name.underscore migration_template 'migration.erb', 'db/migrate/create_kudos_tables.rb' template 'achievement_group.erb', 'app/models/kudos/achievement_group.rb' template 'achievement.erb', 'app/models/kudos/achievement.rb' template 'users_achievement.erb', 'app/models/kudos/users/achievement.rb' template 'achievementable.erb', 'app/models/concerns/kudos/achievementable.rb' template 'uuidable.erb', 'app/models/concerns/kudos/uuidable.rb' end |
#migration_version ⇒ Object
38 39 40 |
# File 'lib/generators/kudos/active_record_generator.rb', line 38 def migration_version self.class.migration_version end |