From 8fce13d83aaacb289543344faf6b2167881c5d18 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 16:58:01 +0800 Subject: [PATCH] fix bug --- app/controllers/zips_controller.rb | 7 ++++--- config/initializers/pdfkit.rb | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index f0ab50001..41407f876 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -20,6 +20,7 @@ class ZipsController < ApplicationController exercises = ExportExercisesService.new(@exercise,@ex_users) file_name = filename_for_content_disposition(exercises.filename) + logger.info("##################_______________________file_name_____________________############{file_name}") send_file exercises.ex_zip, filename: file_name, type: 'application/zip' rescue Exception => e normal_status(-1, e.message) @@ -39,14 +40,14 @@ class ZipsController < ApplicationController def get_exercise ActiveRecord::Base.transaction do begin - @exercise = Exercise.find_by(id:params[:exercise_id]) + @exercise = Exercise.find_by(id:params[:exercise_id]).includes(:exercise_users) group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") else - @course = @exercise.course + @course = @exercise.course.includes(:course_members) - default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed.limit 2 + default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed default_ex_users_size = default_ex_users.size @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 556076f4b..0cd80c9c7 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -1,7 +1,8 @@ PDFKit.configure do |config| - # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' - config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' + config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' + # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' config.default_options = { + encoding: "UTF-8", page_size: 'A4', print_media_type: true, dpi: 300,