diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-13 17:33:32 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-13 17:33:32 +0100 |
commit | ed8e0ac76bddab0d74095313f36bd836d30dcb84 (patch) | |
tree | ef32494d2e2db0296869b534f291904cb732882c /app/models | |
parent | 12a6b6ec57d67da3d4969378a0d930042bcc97bd (diff) |
The convertion of PDFs to fax thumbnails now gets done by a delayed_job.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/fax_document.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index 4db4980..564d3bb 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -18,8 +18,8 @@ class FaxDocument < ActiveRecord::Base has_many :fax_thumbnails, :order => :position, :dependent => :destroy - after_create :render_thumbnails after_create :convert_pdf_to_tiff + after_create :render_thumbnails # Scopes scope :inbound, where(:state => 'inbound') @@ -51,8 +51,12 @@ class FaxDocument < ActiveRecord::Base def to_s "#{self.remote_station_id}-#{self.created_at}-#{self.id}".gsub(/[^a-zA-Z0-9]/,'') end - + def render_thumbnails + self.delay.create_thumbnails_and_save_them + end + + def create_thumbnails_and_save_them tmp_dir = "/tmp/fax_convertions/#{self.id}" FileUtils.mkdir_p tmp_dir system("cd #{tmp_dir} && convert #{self.document.path} -colorspace Gray PNG:'fax_page.png'") |