2

I am trying to use the following script to generate jpgs for pdf files without success.

https://gist.github.com/3059321

I am hoping someone can provide me with a little bit of assistance in making it work. I have spent quite a bit of time struggling with it.

I have an older development environment:

shajizaidi@Spock:~/Softdev/e-mangue/script$ rails -v
Rails 2.3.8
shajizaidi@Spock:~/Softdev/e-mangue/script$ ruby -v
ruby 1.8.7 (2011-12-28 patchlevel 357) [i686-linux]

And relevant gems:

aasm (3.0.1)
actionmailer (2.3.8, 2.2.2)
actionpack (2.3.8, 2.2.2)
activemodel (3.1.3)
activerecord (2.3.8, 2.2.2)
activeresource (2.3.8, 2.2.2)
activesupport (3.1.3, 2.3.8, 2.2.2)
arel (2.2.1)
git (1.2.5)
hpricot (0.8.5)
httpclient (2.2.4)
mysql (2.8.1)
passenger (3.0.11)
rack (1.4.0, 1.1.3)
rails (2.3.8, 2.2.2)
rake (0.9.2)
ruby-blockcache (0.2)
rubygems-update (1.5.3)
rubyist-aasm (2.1.1)
soap4r (1.5.8)

The excerpt from my Model is below:

class Issue < ActiveRecord::Base
include AASM

   belongs_to :publication
   has_many :readings
   has_many :readers, :through => :readings, :class_name => "User"

   has_many :issue_metadatas, :dependent => :destroy
   has_many :table_of_contents_entries, :dependent => :destroy

   has_many :issue_ratings

   has_one :issue_status, :dependent => :destroy

   has_attached_file :pdf,
                    :url  => "/assets/:id/",
                    :path => ":rails_root/assets/docs/:id/:style/:basename.:extension",
                     :styles => {
                                 :icon => ["60X80#", :jpg], 
                                 :thumb => ["360x480#", :jpg]
                                 :large => ["X800", :jpg]
                                 },
                     :processors => [:ghostscript, :thumbnail],
                     :convert_options => {:all => ' colorspace RGB  flatten  density 300  quality 100'},
                     :path => ":page_path/:class/:id/:resource_token/:style/:filename"

   validates_presence_of     :issue_number
   validates_presence_of     :title
   validates_presence_of     :date

When I try to upload a pdf I get the following error:

 RuntimeError (cannot generate tempfile `'):
  /home/shajizaidi/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/1.8/tempfile.rb:52:in `initialize'
  lib/paperclip_processors/ghostscript.rb:17:in `new'
  lib/paperclip_processors/ghostscript.rb:17:in `make'
  app/controllers/issues_controller.rb:79:in `new'
  app/controllers/issues_controller.rb:79:in `create'

In ghostscript.rb

To test if I change the way the temp file is being generated by not using an array for example:

dst = Tempfile.new(“#@basename})

instead of:

dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])

I don't get the error; but then of course the file name of the temp file is not correctly generated.

I have tried to research this quite a bit and cant seem to find a solution.

Puce
  • 1,003
  • 14
  • 28

0 Answers0