数据库误删除的问题
This commit is contained in:
parent
ebc307db07
commit
7eb5317696
|
@ -8,19 +8,24 @@ class StoresController < ApplicationController
|
|||
name = params[:name] ||= ''
|
||||
redirect_to stores_path, :notice => l(:field_course_un) if name.blank?
|
||||
# 按文件名搜索
|
||||
result = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%").
|
||||
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%").
|
||||
reorder("created_on DESC")
|
||||
# result = result.to_a
|
||||
result.map { |res|
|
||||
if(res.container.nil? ||
|
||||
(res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
(res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
false
|
||||
)
|
||||
result.delete(res)
|
||||
end
|
||||
}
|
||||
|
||||
result = resultSet.to_a.dup
|
||||
|
||||
# result.map { |res|
|
||||
# if(res.container.nil? ||
|
||||
# (res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
# (res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
# (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
# false
|
||||
# )
|
||||
# logger.debug("=====================================#{result.include? res}")
|
||||
# logger.debug("=====================================#{res}")
|
||||
# result.delete(res)
|
||||
# logger.debug("=====================================#{result.include? res}")
|
||||
# end
|
||||
# }
|
||||
@searched_attach = paginateHelper result
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue