Class: SeparateHistory::Generators::ModelGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- SeparateHistory::Generators::ModelGenerator
- Defined in:
- lib/generators/separate_history/model/model_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_migration_file ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/separate_history/model/model_generator.rb', line 11 def create_migration_file # if exists history class, skip migration and tell run seperate_histaor:migration name if Object.const_defined?(history_class_name) say_status :skipped, "History class #{history_class_name} already exists. "\ "Run `rails g separate_history:migration #{name}` to create a migration for it.", :yellow nil else migration_template "migration.rb.erb", "db/migrate/create_#{file_name}_history.rb" say_status :created, "Migration for #{history_class_name} created successfully.", :green end end |
#create_model_file ⇒ Object
23 24 25 26 |
# File 'lib/generators/separate_history/model/model_generator.rb', line 23 def create_model_file @original_class = name.classify.constantize template "model.rb.erb", "app/models/#{file_name}_history.rb" end |