Class: TranslationForGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/translation_for_generator.rb

Instance Method Summary collapse

Instance Method Details

#check_attributesObject



10
11
12
13
14
15
16
# File 'lib/generators/translation_for_generator.rb', line 10

def check_attributes
  puts table_name
  if attributes.blank?
    puts "Define at least one translated attribute"
    exit
  end
end

#create_modelObject



18
19
20
# File 'lib/generators/translation_for_generator.rb', line 18

def create_model
  template 'model.rb.erb', File.join('app/models', class_path, "#{file_name}.rb")
end

#create_translations_migrationObject



22
23
24
# File 'lib/generators/translation_for_generator.rb', line 22

def create_translations_migration
  migration_template 'migration.rb.erb', "db/migrate/create_#{table_name}"
end