Sha256: d1ba9ffbc418822d2c3630fbdb5afab5789bd429602e700d6c153ae5a33ec492
Contents?: true
Size: 933 Bytes
Versions: 2
Compression:
Stored size: 933 Bytes
Contents
class LocalizeImages < ActiveRecord::Migration def locale I18n.default_locale end def up Image.all.in_locale(locale).each do |image| unless image.attributes["byline"].blank? Localization.create( localizable: image, name: "caption", locale: locale, value: image.attributes["byline"] ) end end remove_column :images, :name, :string remove_column :images, :byline, :string remove_column :images, :description, :string end def down add_column :images, :name, :string add_column :images, :byline, :string add_column :images, :description, :string Localization.where( localizable_type: "Image", name: "caption", locale: locale ).each do |localization| localization.localizable.update_column( "byline", localization.value ) localization.destroy end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.4.3 | db/migrate/20150401131300_localize_images.rb |
pages_core-3.4.2 | db/migrate/20150401131300_localize_images.rb |