Skip to content

Instantly share code, notes, and snippets.

@victorgiraldes
Last active October 14, 2019 17:19
Show Gist options
  • Save victorgiraldes/ee7a63705c79a843a954631e3311dc77 to your computer and use it in GitHub Desktop.
Save victorgiraldes/ee7a63705c79a843a954631e3311dc77 to your computer and use it in GitHub Desktop.
data migrate
Group.all.each do |group|
Expense.where(company_id: group.company_ids).each do |expense|
next unless expense.procedure
expense_procedure = expense.procedure.description
group_procedures = group.procedures.where(description: expense_procedure).first
expense.update(procedure_id: group_procedures.id)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment