Created
January 10, 2018 20:12
-
-
Save JamesDullaghan/05dc3d068015ae4c72f5880e3a1fa228 to your computer and use it in GitHub Desktop.
Revisions
-
JamesDullaghan created this gist
Jan 10, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ *To Only remove task templates and recreate* ```ruby # find source team src_team = Team.find 836 # find each org iserve = Organization.find 575 idirect = Organization.find 574 idirect_operable_teams = idirect.teams.where.not(id: 836) iserve_operable_teams = iserve.teams # remove old templates first idirect_operable_teams.each { |t| t.loan_file_templates.destroy_all } iserve_operable_teams.each { |t| t.loan_file_templates.destroy_all } iserve_operable_teams.each do |dst_team| src_team.loan_file_templates.order(:id).each do |loan_file_template| LoanFileTemplates::CopyTemplateToAnotherTeam.perform(loan_file_template, dst_team) end end idirect_operable_teams.each do |dst_team| src_team.loan_file_templates.order(:id).each do |loan_file_template| LoanFileTemplates::CopyTemplateToAnotherTeam.perform(loan_file_template, dst_team) end end ``` ```