fixes loading samples error in blank project

This commit is contained in:
zmagod 2016-08-10 09:13:12 +02:00
parent 890b0ba860
commit deb739efa6

View file

@ -134,11 +134,18 @@ class SampleDatatable < AjaxDatatablesRails::Base
@assigned_samples = @project.assigned_samples
ids = @project.my_modules_ids
samples = samples.joins("LEFT OUTER JOIN sample_my_modules ON
(samples.id = sample_my_modules.sample_id AND
(sample_my_modules.my_module_id IN (#{ids}) OR
sample_my_modules.id IS NULL))")
.references(:sample_my_modules)
if ids.blank?
samples = samples.joins('LEFT OUTER JOIN sample_my_modules ON
(samples.id = sample_my_modules.sample_id AND
sample_my_modules.id IS NULL)')
.references(:sample_my_modules)
else
samples = samples.joins("LEFT OUTER JOIN sample_my_modules ON
(samples.id = sample_my_modules.sample_id AND
(sample_my_modules.my_module_id IN (#{ids}) OR
sample_my_modules.id IS NULL))")
.references(:sample_my_modules)
end
elsif @experiment
@assigned_samples = @experiment.assigned_samples
ids = @experiment.my_modules.select(:id)