修复学号为空下载附件报错的BUG
This commit is contained in:
parent
c067d3e4c5
commit
f46240a5eb
|
@ -44,7 +44,7 @@ class ZipdownController < ApplicationController
|
||||||
if homework != nil
|
if homework != nil
|
||||||
unless homework.attachments.empty?
|
unless homework.attachments.empty?
|
||||||
zipfile = zip_homework_by_user homework
|
zipfile = zip_homework_by_user homework
|
||||||
send_file zipfile, :filename => (homework.user.user_extensions.student_id.nil? ? "" : homework.user.user_extensions.student_id) +
|
send_file zipfile, :filename => (homework.user.user_extensions.nil? ? "" : homework.user.user_extensions.student_id) +
|
||||||
"_" + (homework.user.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) +
|
"_" + (homework.user.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) +
|
||||||
"_" + homework.name + ".zip", :type => detect_content_type(zipfile) if(zipfile)
|
"_" + homework.name + ".zip", :type => detect_content_type(zipfile) if(zipfile)
|
||||||
else
|
else
|
||||||
|
@ -80,7 +80,7 @@ class ZipdownController < ApplicationController
|
||||||
homeattach.attachments.each do |attach|
|
homeattach.attachments.each do |attach|
|
||||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||||
end
|
end
|
||||||
zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{(homework.user.user_extensions.student_id.nil? ? "" : homework.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{(homework.user.user_extensions.nil? ? "" : homework.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue