From 3b7e8483e34db8ce9701dad4a539fdc487901747 Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 7 Mar 2014 08:53:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/attachments_helper.rb | 6 +++--- app/views/files/index.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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) %>文件共享专区
- <%= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %> + <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
-