mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 10:24:30 +08:00
Add scope instead of method for active my_module_group
This commit is contained in:
parent
5825c7120d
commit
0e14c126e5
3 changed files with 6 additions and 8 deletions
|
@ -100,12 +100,6 @@ class Experiment < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def active_module_groups
|
||||
my_module_groups.joins(:my_modules)
|
||||
.where('my_modules.archived = ?', false)
|
||||
.distinct
|
||||
end
|
||||
|
||||
def active_modules
|
||||
my_modules.where(archived: false)
|
||||
end
|
||||
|
|
|
@ -10,6 +10,10 @@ class MyModuleGroup < ApplicationRecord
|
|||
optional: true
|
||||
has_many :my_modules, inverse_of: :my_module_group, dependent: :nullify
|
||||
|
||||
scope :active, (lambda do
|
||||
joins(:my_modules).where('my_modules.archived = ?', false).distinct
|
||||
end)
|
||||
|
||||
def deep_clone_to_experiment(current_user, experiment)
|
||||
clone = MyModuleGroup.new(
|
||||
created_by: created_by,
|
||||
|
|
|
@ -41,8 +41,8 @@ module ModelExporters
|
|||
my_modules = @experiment.my_modules
|
||||
my_module_groups = @experiment.my_module_groups
|
||||
else
|
||||
my_modules = @experiment.active_my_modules
|
||||
my_module_groups = @experiment.active_module_groups
|
||||
my_modules = @experiment.my_modules.active
|
||||
my_module_groups = @experiment.my_module_groups.active
|
||||
end
|
||||
return {
|
||||
experiment: @experiment,
|
||||
|
|
Loading…
Add table
Reference in a new issue