db/data_migration/20160913074327_manually_fix_related_mainstream_content_urls_not_found.rb
# This does the update - field_name should either be
# :related_mainstream_content_url or
# :additional_related_mainstream_content_url
# depending on which field is to be updated
This does the update - field_name should either be
:related_mainstream_content_url or
:additional_related_mainstream_content_url
depending on which field is to be updated
This does the update - field_name should either be : related_mainstream_content_url or : additional_related_mainstream_content_url depending on which field is to be updated
def update_related_mainstream_url(field_name, current_mainstream_url, fixed_url)
  detailed_guides = DetailedGuide.where(field_name => current_mainstream_url).where.not(state: "superseded")
  detailed_guides.each do |detailed_guide|
    detailed_guide.update!(field_name => fixed_url)
    puts "Fixed #{detailed_guide.id}, #{field_name}, #{current_mainstream_url}, #{fixed_url}"
  end
end
def update_related_mainstream_url ( field_name , current_mainstream_url , fixed_url ) detailed_guides = DetailedGuide . where ( field_name => current_mainstream_url ) . where . not ( state : "superseded" ) detailed_guides . each do | detailed_guide | detailed_guide . update! ( field_name => fixed_url ) puts "Fixed #{detailed_guide.id}, #{field_name}, #{current_mainstream_url}, #{fixed_url}" end end
This does the update - field_name should either be
:related_mainstream_content_url or
:additional_related_mainstream_content_url
depending on which field is to be updated
This does the update - field_name should either be : related_mainstream_content_url or : additional_related_mainstream_content_url depending on which field is to be updated
field_name
current_mainstream_url
fixed_url