diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index a3080fbfd..7d5db3012 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -88,7 +88,7 @@ module AttachmentsHelper def render_attachments_for_new_project(project, limit=nil) # 查询条件 params[:q] ||= "" - filename_condition = params[:q] + filename_condition = params[:q].strip attachAll = Attachment.scoped # 当前项目所有资源 @@ -96,13 +96,13 @@ module AttachmentsHelper # attachments = Attachment.where("container_type = '#{project.class}' and container_id = #{project.id}") # 除去当前项目的所有资源 - nobelong_attach = Attachment.where("container_type <> '#{project.class}' and container_id <> #{project.id}") unless project.blank? + nobelong_attach = Attachment.where("!(container_type = '#{project.class}' and container_id = #{project.id})") unless project.blank? # 搜索域确定 domain = project.nil? ? attachAll : nobelong_attach # 搜索到的资源 - searched_attach = domain.where("filename like '%#{filename_condition}%' ").limit(limit).order('created_on desc') + searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc') searched_attach = private_filter searched_attach searched_attach = paginateHelper(searched_attach, 10) diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 508aa502b..3012c0a21 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -115,9 +115,9 @@ div.pagination{ <%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>文件共享专区