fix metacode asset path update db migration

This commit is contained in:
Devin Howard 2016-01-20 10:18:22 +08:00
parent 3aea952e40
commit 0e7690f2af
2 changed files with 12 additions and 9 deletions

View file

@ -1,9 +0,0 @@
class MetacodeAssetPathUpdate < ActiveRecord::Migration
def change
Metacode.all.each do |metacode|
if metacode.icon.start_with?("/assets/icons/")
metacode.update(icon: metacode.icon.gsub(/^\/assets\/icons/, "https://s3.amazonaws.com/metamaps-assets/metacodes"))
end
end
end
end

View file

@ -0,0 +1,12 @@
class MetacodeAssetPathUpdate < ActiveRecord::Migration
def change
Metacode.first(50).each do |metacode|
if metacode.icon.start_with?("/assets/icons/")
metacode.icon = metacode.icon.sub(/^\/assets\/icons/, "https://s3.amazonaws.com/metamaps-assets/metacodes")
metacode.icon = metacode.icon.sub('blueprint_96px', 'blueprint/96px')
metacode.icon = metacode.icon.sub('generics_96px', 'generics/96px')
metacode.save
end
end
end
end