views:

177

answers:

1

I'm very confused here as to why paperclip isn't working for me.

When accessing a previously saved file on s3 for processing this method of the paperclip s3 storage class causes an error:

  def to_file style = default_style
    return @queued_for_write[style] if @queued_for_write[style]
    filename = path(style).split(".")
    extname  = File.extname(filename)

What is happening is the path is being split into an array which then isn't accepted by File.extname which returns the error "can't convert Array into String".

I'd really appreciate some advice on this; maybe my path is wrong but I cannot see how split is going to return anything but the array which causes an error on File.extname. This works fine in development but not on heroku where it worked previous to last weekend.

Thank in advance.

EDIT

Have added a weighty bounty on this which reflects my ongoing frustration. Really if someone can help me troubleshoot this I'd be incredibly grateful. I've ruled out previous doubts I had, that maybe it was the heroku repository, by freshly installing the app again.

All pertinent code as far as I can tell:

#photo.rb
has_attached_file :photo,
    :styles => { 
    :list => "150x100#",
    :article => "264>x210",
    :large   => "558>x380",
    :original => "1024>x768"
    },
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:url => ":s3_alias_url",
:s3_host_alias => "files.mydomain.com", #s3 bucket with dns cname record to subdomain
:path => "/photos/:hashed_path/:style/:id.:extension"


#config/s3.rb
bucket: files.mydomain.com
access_key_id: *******************
secret_access_key: **********************************
+1  A: 

A bug in the newest revisions of paperclip is responsible for this. Go back to an older version (looks like 2.3.3 doesn't have this problem) and that ought to fix it.

Here's the commit where the bug was introduced. Someone even commented that it was probably a bug:

http://github.com/thoughtbot/paperclip/commit/1fef4c302d076575a1ca9691e01eb96ee9262ebc#commitcomment-166132

My theory for why this works locally but no on Heroku is because the filesystem path that's being manipulated in the to_file method is different in each environment, and the one on Heroku is affected by this bug but somehow your local path is skirting it.

tfe
Oh my ... you didn't :O
mark
Keep going, this just became the most fun thread I've read on Stack Overflow in a few days.
pjmorse
How about coffee splllluuurrrtttt... So yeah this fixed everything. Thanks tfe! Cha ching huh. My debugging from this point on will include plugin commit comments. Oh you have to wait for 18 hours for your pressie.
mark