diff --git a/app/models/experiment.rb b/app/models/experiment.rb index 3df1cfc85..334a2b626 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -761,8 +761,6 @@ class Experiment < ApplicationRecord workflows = [] dg.to_undirected.each_connected_component { |w| workflows << w } - # Retrieve maximum allowed module group name - max_length = (MyModuleGroup.validators_on(:name).select { |v| v.class == ActiveModel::Validations::LengthValidator }).first.options[:maximum] # For each workflow, generate new names new_index = 1 wf_names = [] @@ -788,16 +786,16 @@ class Experiment < ApplicationRecord name = I18n.t("my_module_groups.new.name", index: new_index) new_index += 1 end - elsif name.length > max_length + elsif name.length > Constants::NAME_MAX_LENGTH # If length is too long, shorten it - name = name[0..(max_length + cut_index)] + suffix + name = name[0..(Constants::NAME_MAX_LENGTH + cut_index)] + suffix end wf_names << name end # Remove any existing module groups from modules - unless MyModuleGroup.destroy_all(:id => group_ids.to_a) + unless MyModuleGroup.where(id: group_ids.to_a).destroy_all raise ActiveRecord::ActiveRecordError end diff --git a/app/models/my_module.rb b/app/models/my_module.rb index 2cd0112aa..820add1f6 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -135,10 +135,10 @@ class MyModule < ApplicationRecord MyModule.transaction do archived = super # Unassociate all samples from module. - archived = SampleMyModule.destroy_all(:my_module => self) if archived + archived = SampleMyModule.where(my_module: self).destroy_all if archived # Remove all connection between modules. - archived = Connection.delete_all(:input_id => id) if archived - archived = Connection.delete_all(:output_id => id) if archived + archived = Connection.where(input_id: id).delete_all if archived + archived = Connection.where(output_id: id).delete_all if archived unless archived raise ActiveRecord::Rollback end