class TranslationCenter::InstallGenerator

Public Class Methods

next_migration_number(path) click to toggle source
# File lib/generators/translation_center/install/install_generator.rb, line 8
def self.next_migration_number(path)
  @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S%6N").to_i.to_s
end

Public Instance Methods

install_translation() click to toggle source
# File lib/generators/translation_center/install/install_generator.rb, line 12
def install_translation
  # Generate migration templates for the models needed
  migration_template 'migrations/create_translation_center_categories.rb', 'db/migrate/create_translation_center_categories.rb'
  migration_template 'migrations/create_translation_center_translation_keys.rb', 'db/migrate/create_translation_center_translation_keys.rb'
  migration_template 'migrations/create_translation_center_translations.rb', 'db/migrate/create_translation_center_translations.rb'

  # generate votes if it doesn't already exist
  unless ActiveRecord::Base.connection.table_exists? 'votes'
    Rails::Generators.invoke('acts_as_votable:migration')
  end
  
  copy_file 'config/translation_center.yml', 'config/translation_center.yml'

  # user can replace this logo to change the logo
  copy_file 'assets/translation_center_logo.png', 'app/assets/images/translation_center_logo.png'

  sleep(1) # to avoid duplicate migrations between acts_as_votable and auditable

  unless ActiveRecord::Base.connection.table_exists? 'audits'
    # we use audited for tracking activity
    Rails::Generators.invoke('audited:install')
  end
end