Fix bug for rails 4.2.

This commit is contained in:
BoHung Chiu 2023-08-15 21:17:57 +08:00
parent 3be81db424
commit 5f73eedbdd
1 changed files with 2 additions and 1 deletions

View File

@ -7,6 +7,7 @@ class Admin::GalleriesController < OrbitAdminController
layout :compute_layout
find_tag = Tag.all.select{|value| value.name==I18n.t('gallery.not_show_desc')}
RackTempMiddleExist = defined?(Rack::TempfileReaper)
RACK_TEMPFILES = defined?(Rack::RACK_TEMPFILES) ? Rack::RACK_TEMPFILES : 'rack.tempfiles'
if find_tag.length==0
module_app_id = ModuleApp.where(:key=>"gallery").first[:_id]
tags = ModuleApp.where(:key=>"gallery").first.tags
@ -559,7 +560,7 @@ class Admin::GalleriesController < OrbitAdminController
album_unprocess.save_var = file
album_unprocess.save!
ObjectSpace.undefine_finalizer(file.tempfile)
request.set_header(Rack::RACK_TEMPFILES, []) if RackTempMiddleExist # Avoid Rack::TempfileReaper Middleware to unlink temp files automatically.
request.set_header(RACK_TEMPFILES, []) if RackTempMiddleExist # Avoid Rack::TempfileReaper Middleware to unlink temp files automatically.
end
image.save!
end