Skip to content

Instantly share code, notes, and snippets.

@PeteMichaud
PeteMichaud / gist:fd5ccea6f4d792188f459d3405d5e18d
Last active June 10, 2016 21:22 — forked from crova/'campaign_records'
iterates through each row but keep updating on the same db row
# fetchs SIB Campaigns
def fetch
# update/create
campaign_records.each do |record|
shoot = Shoot.find_or_initialize_by(campaign_id: record[:id])
unless shoot.update(record)
# the data was invalid, so the shoot wasn't saved, do something about that here
end
end