mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 07:26:15 +08:00
refactor
This commit is contained in:
parent
f079a097c5
commit
04ee24d553
|
@ -53,7 +53,7 @@ class TeamsController < ApplicationController
|
||||||
)
|
)
|
||||||
|
|
||||||
if @temp_file.save
|
if @temp_file.save
|
||||||
@temp_file.destroy_obsolete_files
|
@temp_file.destroy_obsolete
|
||||||
# format.html
|
# format.html
|
||||||
format.json {
|
format.json {
|
||||||
render :json => {
|
render :json => {
|
||||||
|
|
|
@ -4,11 +4,10 @@ class TempFile < ActiveRecord::Base
|
||||||
has_attached_file :file
|
has_attached_file :file
|
||||||
do_not_validate_attachment_file_type :file
|
do_not_validate_attachment_file_type :file
|
||||||
|
|
||||||
def destroy_obsolete_files
|
def destroy_obsolete
|
||||||
file = TempFile.find_by_id(self.id)
|
destroy! if self
|
||||||
file.destroy! if file
|
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_asynchronously :destroy_obsolete_files,
|
handle_asynchronously :destroy_obsolete,
|
||||||
run_at: proc { 7.days.from_now }
|
run_at: proc { 7.days.from_now }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue