From 4b95f85480acc2dc70450754bf31f426d9512e7e Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Tue, 2 May 2017 14:50:05 +0200 Subject: [PATCH] A wrong join when searching for documents --- app/models/dmsf_file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index f6b3a5b2..5499e7d5 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -319,7 +319,7 @@ class DmsfFile < ActiveRecord::Base project_conditions << Project.allowed_to_condition(user, :view_dmsf_files) project_conditions << "#{Project.table_name}.id IN (#{project_ids.join(',')})" if project_ids.present? - scope = self.visible.joins(:dmsf_file_revision).joins(:project) + scope = self.visible.joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id').joins(:project) scope = scope.limit(options[:limit]) unless options[:limit].blank? scope = scope.where(limit_options) unless limit_options.blank? scope = scope.where(project_conditions.join(' AND '))