fixed experiments archive bug

This commit is contained in:
zmagod 2016-08-18 10:55:29 +02:00
parent b6ccecf478
commit fa08b861d0
2 changed files with 6 additions and 6 deletions

View file

@ -80,9 +80,6 @@ class ExperimentsController < ApplicationController
@experiment.archived = true
@experiment.archived_by = current_user
@experiment.archived_on = DateTime.now
@experiment.my_modules.each do |my_module|
my_module.archive(current_user)
end
if @experiment.save
flash[:success] = t('experiments.archive.success_flash',
experiment: @experiment.name)

View file

@ -149,12 +149,15 @@ class Project < ActiveRecord::Base
if role.blank?
MyModule.none
elsif role == 'owner'
project_my_modules.where(archived: false)
project_my_modules
.joins(:experiment)
.where('experiments.archived=false')
else
project_my_modules
.joins(:user_my_modules)
.where('user_my_modules.user_id IN (?)', user.id)
.where(archived: false)
.joins(:experiment)
.where('experiments.archived=false AND user_my_modules.user_id IN (?)',
user.id)
.distinct
end
end