【问题标题】:Paperclip + S3 + Nginx issue on image upload回形针 + S3 + Nginx 图片上传问题
【发布时间】:2013-09-09 08:43:29
【问题描述】:

我正在使用带有 S3 的回形针将我的用户图像保存在亚马逊存储桶中。用于将图像保存在 s3.amazonaws.com/my-bucket/users/photos/000/000/1/small/photo.jpg 中的工作版本。当我创建 Male and Female models (subclasses of User) 时,它开始在 s3.amazonaws.com/my-bucket/males/photos/000/000/1/small/photo.jpg (if the user is a male) 中搜索图像。

此外,当我尝试创建新照片时,我得到了 nginx 500 Internal Server Error 并且没有登录 rails 应用程序。

我该如何解决?

【问题讨论】:

    标签: ruby ruby-on-rails-3 amazon-s3 paperclip


    【解决方案1】:

    前段时间我遇到了同样的问题,它对我来说只是重新启动我的网络服务器。我在我的应用程序中使用了Passenger。

    我忘了说我用 Paperclip 方法 Interpolates 创建了一个插值,就像这样:

    #config/initializers/paperclip.rb
    Paperclip.interpolates :class  do |attachment, style|
      attachment.instance.class.model_name.downcase.pluralize
    end
    

    现在 S3 上的文件 url 将使用 .../users/...,而不是 .../males/... 或 .../females/...。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      • 2012-07-07
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      相关资源
      最近更新 更多