Skip to content

Instantly share code, notes, and snippets.

@JamesDullaghan
Created January 10, 2018 20:12
Show Gist options
  • Select an option

  • Save JamesDullaghan/05dc3d068015ae4c72f5880e3a1fa228 to your computer and use it in GitHub Desktop.

Select an option

Save JamesDullaghan/05dc3d068015ae4c72f5880e3a1fa228 to your computer and use it in GitHub Desktop.

Revisions

  1. JamesDullaghan created this gist Jan 10, 2018.
    30 changes: 30 additions & 0 deletions copy_task_list_templates_only.md
    Original 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
    ```
    ```