From 5f925e402f184be672a1d9d84a3a0789a6347bf9 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Wed, 27 May 2026 20:17:46 +0800 Subject: [PATCH] Fix recruitment export: rename view to partial, initialize @module_app in Thread, use binary file mode --- app/controllers/admin/recruitment_controller.rb | 5 +++-- .../{export_excel.xlsx.axlsx => _export_excel.xlsx.axlsx} | 0 2 files changed, 3 insertions(+), 2 deletions(-) rename app/views/admin/recruitment/{export_excel.xlsx.axlsx => _export_excel.xlsx.axlsx} (100%) diff --git a/app/controllers/admin/recruitment_controller.rb b/app/controllers/admin/recruitment_controller.rb index 00d7991..14bdd4e 100644 --- a/app/controllers/admin/recruitment_controller.rb +++ b/app/controllers/admin/recruitment_controller.rb @@ -123,14 +123,15 @@ class Admin::RecruitmentController < OrbitAdminController if update_flag Thread.new do begin + @module_app = ModuleApp.where(:key => 'recruitment_mod').first @recruitment = Recruitment.where(:category_id.ne=>nil).desc(:created_at) last_updated = Recruitment.max(:updated_at).to_i filename = "public/recruitment_export_#{last_updated}.xlsx" if File.exist?(filename) @thread.update(:status=>{:status=>'finish','finish_percent'=>100,'info'=>I18n.t('recruitment.read_from_cache')}) else - excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] , layout: false, template: 'admin/recruitment/export_excel.xlsx', locals: {:@recruitment=>@recruitment,:@thread=>@thread} ) - File.open(filename, 'w') do |f| + excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] , partial: 'export_excel.xlsx' ) + File.open(filename, 'wb') do |f| f.write excel_contents end end diff --git a/app/views/admin/recruitment/export_excel.xlsx.axlsx b/app/views/admin/recruitment/_export_excel.xlsx.axlsx similarity index 100% rename from app/views/admin/recruitment/export_excel.xlsx.axlsx rename to app/views/admin/recruitment/_export_excel.xlsx.axlsx