Sha256: e3c848becdc92e40dddec9625bd93a94c8ccaa80ae934bcf5ef2e6750e828f3b

Contents?: true

Size: 534 Bytes

Versions: 4

Compression:

Stored size: 534 Bytes

Contents

class MigrateOldUrls < ActiveRecord::Migration
  class Monologue::PostsRevision < ActiveRecord::Base
  end

  def up
    mount_point = Monologue::Engine.routes.url_helpers.root_path
    Monologue::PostsRevision.all.each do |r|
      next if r.url.nil?
      r.url = r.url.sub(mount_point, "")
      r.save!
    end
  end

  def down
    mount_point = Monologue::Engine.routes.url_helpers.root_path
    Monologue::PostsRevision.all.each do |r|
      next if r.url.nil?
      r.url = mount_point + r.url
      r.save!
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
monologue-0.5.0 db/migrate/20120526131841_migrate_old_urls.rb
monologue-0.4.1 db/migrate/20120526131841_migrate_old_urls.rb
monologue-0.4.0 db/migrate/20120526131841_migrate_old_urls.rb
monologue-0.3.0 db/migrate/20120526131841_migrate_old_urls.rb