Add rake to move external_url to description
This rake move this field for Proposals and Legislation proposals.
This commit is contained in:
23
lib/tasks/proposals.rake
Normal file
23
lib/tasks/proposals.rake
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace :proposals do
|
||||
|
||||
desc "Move external_url to description"
|
||||
task move_external_url_to_description: :environment do
|
||||
include ActionView::Helpers::SanitizeHelper
|
||||
include TextWithLinksHelper
|
||||
|
||||
models = [Proposal, Legislation::Proposal]
|
||||
|
||||
models.each do |model|
|
||||
print "Move external_url to description for #{model}s"
|
||||
model.find_each do |resource|
|
||||
if resource.external_url.present?
|
||||
resource.update_columns(description: "#{resource.description} "\
|
||||
"<p>#{text_with_links(resource.external_url)}</p>",
|
||||
external_url: "")
|
||||
print "."
|
||||
end
|
||||
end
|
||||
puts " ✅ "
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user