Sha256: 3f386791bc04abf4981495853d9a8db4bfd3b79836352e69e0a4a5e8ecf96ba3

Contents?: true

Size: 871 Bytes

Versions: 12

Compression:

Stored size: 871 Bytes

Contents

class RenameQbrickPagesUrlToPath < ActiveRecord::Migration
  def up
    I18n.available_locales.each do |locale|
      rename_column :qbrick_pages, :"url_#{locale.to_s.underscore}", :"path_#{locale.to_s.underscore}"
    end

    pages = Qbrick::Page.unscoped.all

    I18n.available_locales.each do |locale|
      I18n.with_locale(locale) do
        pages.each do |page|
          page.update_attribute :path, page.create_path
        end
      end
    end
  end

  def down
    I18n.available_locales.each do |locale|
      rename_column :qbrick_pages, :"path_#{locale.to_s.underscore}", :"url_#{locale.to_s.underscore}"
    end

    pages = Qbrick::Page.unscoped.all

    I18n.available_locales.each do |locale|
      I18n.with_locale(locale) do
        pages.each do |page|
          page.update_attribute :url, page.create_path
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
qbrick-2.7.1 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.7 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.10 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.9 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.8 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.7 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.6 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.5 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.4 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.3 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.2 db/migrate/25_rename_qbrick_pages_url_to_path.rb
qbrick-2.6.1 db/migrate/25_rename_qbrick_pages_url_to_path.rb