Skip to content

Instantly share code, notes, and snippets.

@ardeearam
Last active December 10, 2015 04:14
Show Gist options
  • Save ardeearam/f423871f2cde90c2405f to your computer and use it in GitHub Desktop.
Save ardeearam/f423871f2cde90c2405f to your computer and use it in GitHub Desktop.
ReferralDocument.each do |r|
begin
referral_master = Referral.find(r.referral_id)
r.update(service_id: referral_master.master_service.id, reference: referral_master.reference)
rescue ActiveRecord::RecordNotFound => ex1
puts ex1.class.name + " " + ex1.message + ". Deleting mongo Referral cache..."
r.destroy
rescue StandardError => ex2
puts ex2.class.name + " " + ex2.message
r.destroy
end
end
#Try also Referral.all.each {|r| r.sync_with_cache}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment