diff options
-rw-r--r-- | app/models/restore_job.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/models/restore_job.rb b/app/models/restore_job.rb index 2c2da54..571d967 100644 --- a/app/models/restore_job.rb +++ b/app/models/restore_job.rb @@ -3,11 +3,24 @@ class RestoreJob < ActiveRecord::Base mount_uploader :backup_file, BackupFileUploader + after_create :queue_the_restore_rake_task + def to_s if self.backup_file? File.basename(self.backup_file.to_s) else "RestoreJob ID #{self.id}" end - end + end + + private + def queue_the_restore_rake_task + self.delay.run_the_restore_rake_task + end + + def run_the_restore_rake_task + system "cd #{Rails.root} && rake backup:restore" + end + + end |