Sha256: cd3abf8b7629159c75754966edeced55457778099c808717982a968809e8f2d0

Contents?: true

Size: 527 Bytes

Versions: 12

Compression:

Stored size: 527 Bytes

Contents

class PopulateTranslations < ActiveRecord::Migration
  
  def self.globalizable_content
    Globalize2Extension::GLOBALIZABLE_CONTENT
  end
  
  def self.up    
    globalizable_content.each do |model, columns|
      model.send(:all).each do |item|
        translation = item.translations.find_or_initialize_by_locale(Globalize2Extension.default_language.to_s)
        columns.each do |column|
          translation[column] = item[column]
        end
        translation.save
      end
    end
  end

  def self.down
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
radiant-globalize2-extension-0.3.2 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.3.1 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.3.0 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.8 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.7 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.6 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.5 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.4 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.3 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.2 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.1 db/migrate/20090728114627_populate_translations.rb
radiant-globalize2-extension-0.2.0 db/migrate/20090728114627_populate_translations.rb