Class: ActiveVersion::Generators::TranslationsGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ActiveVersion::Generators::TranslationsGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/active_version/translations/translations_generator.rb
Instance Method Summary collapse
- #create_translation_model ⇒ Object
- #generate_migration_file ⇒ Object
- #inject_has_translations ⇒ Object
Instance Method Details
#create_translation_model ⇒ Object
18 19 20 21 |
# File 'lib/generators/active_version/translations/translations_generator.rb', line 18 def create_translation_model template "translation_model.rb.erb", File.join("app/models", class_path, "#{file_name}_translation.rb") end |
#generate_migration_file ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/active_version/translations/translations_generator.rb', line 23 def generate_migration_file migration_template "migration.rb.erb", File.join("db/migrate", "create_#{table_name}.rb"), migration_version: migration_version end |
#inject_has_translations ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/generators/active_version/translations/translations_generator.rb', line 29 def inject_has_translations model_path = File.join("app/models", class_path, "#{file_name}.rb") return unless File.exist?(model_path) inject_into_class(model_path, class_name) do " has_translations\n" end end |