testcontroller
This commit is contained in:
parent
41f315aac0
commit
31ce41a2d7
|
@ -7,7 +7,7 @@ class TestController < ApplicationController
|
|||
|
||||
bid.homeworks.each do |homeattach|
|
||||
homeattach.attachments.each do |attach|
|
||||
homeworks_attach_path << attach.diskfile
|
||||
homeworks_attach_path << attach.disk_filename
|
||||
end
|
||||
end
|
||||
@paths = homeworks_attach_path
|
||||
|
@ -22,16 +22,16 @@ class TestController < ApplicationController
|
|||
end
|
||||
|
||||
def ziping files_path
|
||||
folder = "/tmp"
|
||||
folder = "#{Rails.root}/files"
|
||||
input_filename = files_path
|
||||
zipfile_name = "/tmp/archive_#{Time.now.to_i}.zip"
|
||||
zipfile_name = "#{Rails.root}/tmp/archive_#{Time.now.to_i}.zip"
|
||||
|
||||
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
||||
input_filename.each do |filename|
|
||||
zipfile.add(filename, folder + '/' + filename)
|
||||
end
|
||||
zipfile.get_ouput_stream("ReadMe"){ |os|
|
||||
os.write "myFile contains just this"
|
||||
os.write "Homeworks"
|
||||
}
|
||||
end
|
||||
zipfile_name
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<%= link_to "package", test_zip_path(:homework_id => homework.id)%><br/>
|
||||
<% homework.homeworks.each do |homeattach|%><%#homework.class == Bid %>
|
||||
<% homeattach.attachments.each do |attach|%>
|
||||
<%= link_to_attachment attach, author: true %> (<%=attach.author%>)
|
||||
<%= link_to_attachment attach, author: true, :download => true %> (<%=attach.author%>)
|
||||
<br/>
|
||||
<% homeworks_attach_path << attach.storage_path %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue