Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

s3 writes fail if attachment :styles is a Proc #1136

Closed
BradRubenstein opened this issue Jan 12, 2013 · 5 comments
Closed

s3 writes fail if attachment :styles is a Proc #1136

BradRubenstein opened this issue Jan 12, 2013 · 5 comments

Comments

@BradRubenstein
Copy link

lib/paperclip/attachment.rb is coded to allow :styles option to be a Proc, called with self as an argument.

lib/paperclip/storage/s3.rb assumes it is a hash, and doesn't call the Proc with self as an argument. (where it is trying to get style_specific_options in #flush_writes )

Thus, this code fails when trying to evaluate attachment.instance:

has_attached_file :attachment, 
    :styles => Proc.new { |attachment| attachment.instance.styles }

def styles
   ...
end

workaround (assumes I'm not ever using s3_options, s3_metadata etc with styles):

:styles => Proc.new { |attachment| attachment.instance.styles rescue {} }
@davydotcom
Copy link

I believe this is related to #1118

@davedx
Copy link

davedx commented Jan 26, 2013

Massive thanks for the workaround.

@maclover7
Copy link
Contributor

Hi @BradRubenstein ! Is this still an issue for you in Paperclip; I know this issue is from approximately 2 years ago. If it is still an issue, can you please provide the code that's causing you the error? Thanks!

@BradRubenstein
Copy link
Author

I'm no longer using it. Regards, - Brad

On 3/9/15 2:10 PM, Jon Moss wrote:

Hi @BradRubenstein https://github.com/BradRubenstein ! Is this still
an issue for you in Paperclip; I know this issue is from approximately
2 years ago. If it is still an issue, can you please provide the code
that's causing you the error? Thanks!


Reply to this email directly or view it on GitHub
#1136 (comment).

@maclover7
Copy link
Contributor

@jferris @jyurek Please close issue, problem appears to be solved.

@tute tute closed this as completed May 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants