Sha256: 2f4b43612bff41b5ae12c4d91914f1cbfde8d1cb89e57ad2a9735554c0bb4101
Contents?: true
Size: 1.11 KB
Versions: 10
Compression:
Stored size: 1.11 KB
Contents
require 'rails/generators' require 'rails/generators/migration' require 'rails/generators/active_record' module Kuhsaft module Translations class Add < Rails::Generators::Base include Rails::Generators::Migration source_root(File.join(Kuhsaft::Engine.root, '/lib/templates/kuhsaft/translations')) argument :locale, type: :string def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end def translated_columns Kuhsaft::Page.column_names.select { |attr| attr.end_with? "_#{I18n.default_locale}" } end def formatted_locale locale.underscore end def create_locale_migration_file migration_template('add_translation.erb', Rails.root.join('db', 'migrate', "add_#{formatted_locale}_translation.rb")) end private def get_attribute(attribute_name = '') attribute_name.gsub("_#{I18n.default_locale}", "_#{formatted_locale}") end def get_type(key = '') Kuhsaft::Page.columns_hash[key].type end end end end
Version data entries
10 entries across 10 versions & 2 rubygems