Last active
October 14, 2019 17:19
-
-
Save victorgiraldes/ee7a63705c79a843a954631e3311dc77 to your computer and use it in GitHub Desktop.
data migrate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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