summaryrefslogtreecommitdiff
path: root/app/models/restore_job.rb
blob: 571d96702bb66fb11c0c99da137446004d882a66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class RestoreJob < ActiveRecord::Base
  attr_accessible :state, :backup_file

  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

  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