【问题标题】:Deploying content from a staging site to production with the, Heroku, CKEditor gem, Paperclip and Amazon S3使用 Heroku、CKEditor gem、Paperclip 和 Amazon S3 将内容从临时站点部署到生产环境
【发布时间】:2013-02-24 15:48:58
【问题描述】:

我有一个使用 ckeditor 的 rails 站点,因此用户可以在该站点上构建页面。通常,他们在临时站点上开发页面并将更改推送到生产服务器。在用户在私有服务器上托管站点和任何图像之前,ckeditor 使用图像的相对路径。比如在ckeditor创建的asset的content字段中:

img src=\"/uploads/images/mypic.jpeg\"

但是,我们现在正在过渡到 Heroku,并且我们正在使用 Amazon S3 来托管文件。结果,ckeditor 必须使用绝对路径。例如:

img src=\"http://mybucket_staging.s3.amazonaws.com/uploads/images/mypic.jpeg\"

这使得从暂存到生产的部署成为问题,因为即使正确的图片在生产存储桶中,当数据库被推送到生产时,ckeditor 资产的内容字段仍将指向暂存存储桶。有没有办法让它更有活力?

【问题讨论】:

    标签: ruby-on-rails heroku amazon-s3 ckeditor paperclip


    【解决方案1】:

    如何使用config var - 在生产和暂存时设置不同的一个 - 并根据此变量的值填充路径?

    【讨论】:

    • 我最终使用了类似的东西。在保存 ckeditor 资产之前,我们在 url 上执行 gsub,根据环境替换存储桶 url。基本上:def show @article = Article.find(params[:id]) @article.content.gsub(/src=(.*?)\/uploads/, "src=\"http://#{ENV['S3_BUCKET']}/uploads")
    猜你喜欢
    • 2012-06-06
    • 1970-01-01
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    相关资源
    最近更新 更多