@ -200,23 +203,10 @@ class FilesController < ApplicationController
ifsort==""
sort="created_on DESC"
end
ids=""
len=0
count=project.versions.count
project.versions.eachdo|version|
len=len+1
iflen!=count
ids+=version.id.to_s+','
else
ids+=version.id.to_s
end
end
ifids.blank?
resultSet=Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ",like:"%#{keywords}%").
reorder(sort)
ifkeywords!="%%"
resultSet=Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ",like:"%#{keywords}%").reorder(sort)
else
resultSet=Attachment.where("((attachments.container_type = 'Project' And attachments.container_id = '#{project.id}') OR (container_type = 'Version' AND container_id IN (#{ids}))) AND filename LIKE :like ",like:"%#{keywords}%").
reorder(sort)
resultSet=Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' ").reorder(sort)