This commit is contained in:
Guo Xiang Tan 2019-04-24 12:20:53 +08:00
parent 149411ec90
commit 3094a603b7
1 changed files with 5 additions and 2 deletions

View File

@ -266,12 +266,15 @@ class Upload < ActiveRecord::Base
) )
remap_scope ||= begin remap_scope ||= begin
Post.with_deleted.where("raw ~ '/uploads/default/\\d+/'").all Post.with_deleted
.where("raw ~ '/uploads/default/\\d+/'")
.select(:raw, :cooked)
.all
end end
remap_scope.each do |post| remap_scope.each do |post|
post.raw.gsub!(previous_url, upload.url) post.raw.gsub!(previous_url, upload.url)
post.cooked.sub!(previous_url, upload.url) post.cooked.gsub!(previous_url, upload.url)
post.save! if post.changed? post.save! if post.changed?
end end