I have the following paperclip setup in my model:
#Paperclip for photo
has_attached_file :photo,
:styles => {
:large => '1024x758>',
:medium => "200x150#",
开发者_开发技巧 :small => "50x50>"
},
:default_style => :original,
:default_url => '/images/:attachment/default_:style.png',
:path => ":instance_id/:attachment/:id/:version/:style/:basename.:extension",
:storage => :s3,
:s3_credentials => File.join(Rails.root, 'config', 's3.yml'),
:s3_protocol => 'https'
for instance_id I have the following:
Paperclip.interpolates :instance_id do |attachment, style|
def instance_id(attachment, style)
attachment.instance.instance_id
end
end
What's happening is when I first fire up the server, I'm noticing 404s with my images. I had thought that was Amazon S3, but then I looked into the URLs, and noticed that sometimes instance_id is not being returned by Paperclip.interpolates.
Any idea why? Have you experienced anything like this?
Thanks
If I understand correctly what you're trying to achieve, then the following should work:
Paperclip.interpolates :instance_id do |attachment, style|
attachment.instance.instance_id
end
FYI: your interpolates proc defines a method, but doesn't actually do something...
Hope this helps,
Peter
精彩评论