This commit is contained in:
yanxd 2014-01-14 17:21:27 +08:00
parent 6a7a6b1be6
commit 91a6c13ced
1 changed files with 11 additions and 7 deletions

View File

@ -8,7 +8,11 @@ class StoresController < ApplicationController
# include ActsAsTaggableOn::TagsHelper
def search
@searched_attach = Attachment.all[0..20]
name = params[:name] ||= ''
@searched_attach = Attachment.includes(:project).where("projects.is_public = ? AND filename LIKE '%"<< name <<"%' ", 1)
# @searched_attach = Attachment.all[0..20]
@searched_attach.take 20
# reutrn @searched_attach
end
LIMIT = 12 unless const_defined?(:LIMIT)
@ -43,12 +47,12 @@ class StoresController < ApplicationController
where("projects.project_type=#{project_type}").
reorder("downloads DESC").
limit(LIMIT)
doc_attach = join_tools_project "documents", project_type
issue_attach = join_tools_project "issues", project_type
mess_attach = []#join_tools_project "messages", project_type
news_attach = join_tools_project "news", project_type
vers_attach = join_tools_project "versions", project_type
wiki_attach = []#join_tools_project "wiki_pages", project_type
doc_attach = join_tools_project "documents", project_type
issue_attach = join_tools_project "issues", project_type
mess_attach = []#join_tools_project "messages", project_type
news_attach = join_tools_project "news", project_type
vers_attach = join_tools_project "versions", project_type
wiki_attach = []#join_tools_project "wiki_pages", project_type
tmp = pro_attach+doc_attach+issue_attach+mess_attach+news_attach+vers_attach+wiki_attach
tmp.sort { |a, b| b.downloads <=> a.downloads }