views:

57

answers:

2

I updated from 2.3.3 to 2.3.5 for the string to array bug, and now when I try to call Model.image.reprocess! I get the following error. Is this something in my code or something in paperclip? Or maybe in the image I'm uploading?

"\xFF" from ASCII-8BIT to UTF-8
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/paperclip-2.3.5/lib/paperclip/storage/s3.rb:134:in `to_file'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/paperclip-2.3.5/lib/paperclip/attachment.rb:219:in `reprocess!'
/home/brian/Dropbox/portfolio/app/models/asset.rb:34:in `regenerate_styles!'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/performable_method.rb:20:in `perform'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/backend/base.rb:77:in `invoke_job'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:118:in `block (2 levels) in run'
/home/brian/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:118:in `block in run'
/home/brian/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:117:in `run'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:176:in `reserve_and_run_one_job'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:102:in `block in work_off'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:101:in `times'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:101:in `work_off'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:76:in `block (2 levels) in start'
/home/brian/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:75:in `block in start'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:72:in `loop'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:72:in `start'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:100:in `run'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:79:in `block in run_process'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `call'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `block in start_proc'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call_as_daemon'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/application.rb:254:in `start_proc'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/application.rb:294:in `start'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in `run'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons.rb:193:in `block in run_proc'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/daemons-1.1.0/lib/daemons.rb:192:in `run_proc'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:78:in `run_process'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:72:in `block in daemonize'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:70:in `times'
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:70:in `daemonize'
script/delayed_job:5:in `<main>'

Relevant model:

class Asset < ActiveRecord::Base
  attr_accessible :image, :image_file_name, :image_content_type, :image_file_size, :portfolio_item_id, :order

  belongs_to :portfolio_item

  has_attached_file :image,
    :styles => {
      :thumb => "20x20#",
      :small => "100x100",
      :large => "600x600>"
               },
    :storage => :s3,
    :s3_credentials => {
      :access_key_id => ENV["S3_KEY"],
      :secret_access_key => ENV["S3_SECRET"]
                       },
    :bucket => ENV["S3_BUCKET"],
    :path => "portfolio/:attachment/:id/:style/:basename.:extension"

  before_image_post_process do |image|
    if changed?
      processing = true
      false
    end
  end

  after_save do |image|
    if image.changed?
      send_later(:regenerate_styles!)
    end
  end

  def regenerate_styles!
    self.image.reprocess!
    self.processing = false
    self.save(false)
  end

  def changed?
    self.image_file_size_changed? ||
    self.image_file_name_changed? ||
    self.image_content_type_changed? ||
    self.image_update_at_changed?
  end
end
A: 

It's a bug with paperclip. Revert to the previous version and you'll be fine. This really had me pulling my hair out for a few days as well. :)

mark
Hum. Is it fixed in the master branch? I may just have to check that out. It's not like anything is going to go wrong if I put a git repo in production code, right? ;)
Reactor5
Looks like it's been fixed 3 days ago actually so updating the gem should work. It taught me to specify a gem version the hard way as it frunked up my production application on heroku. :)
mark
What version of the gem are you using? I'm on 2.3.5 and it's doing this to me.
Reactor5
Oh well this looks like a new bug. The to_file string to array bug was introduced in 2.3.4; 2.3.3 is working fine for me on rails 2.3.
mark