【问题标题】:deploying assets to S3 via Heroku using assets_s3使用 assets_s3 通过 Heroku 将资产部署到 S3
【发布时间】:2012-11-03 19:18:29
【问题描述】:

我关注了guide from Heroku 通过添加环境变量并添加

config.action_controller.asset_host = "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"

到环境/production.rb

我看到资产已上传到我的 s3 存储桶,我可以访问它们。

但在我的网站上,我没有看到任何使用asset_path 标签的资产,例如css

background-image: url("<%= asset_path "image.jpg" %>");

当我查看源代码时,我看到一个指向如下文件的链接:

url("https://.s3.amazonaws.com/assets/image.jpg")

这很奇怪,因为 css 和 js 可以工作(使用 FOG_DIRECTORY 变量)。那么为什么这里会跳过 FOG_DIRECTORY env 就好像它不存在一样呢?

【问题讨论】:

    标签: ruby-on-rails-3 heroku amazon-s3 assets fog


    【解决方案1】:

    解决了

    config.asset_host = "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
    

    并使用

    heroku labs:enable user-env-compile
    

    【讨论】:

    • 你能解释一下config.asset_host和config.action_controller.asset_host的区别吗?试图弄清楚如何使用 CDN 和单独的存储桶来上传图像。
    • 根据guides.rubyonrails.org/configuring.html是一样的config.asset_host sets the host for the assets. Useful when CDNs are used for hosting assets, or when you want to work around the concurrency constraints builtin in browsers using different domain aliases. Shorter version of config.action_controller.asset_host.
    猜你喜欢
    • 2016-02-04
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 2011-11-20
    • 2015-09-10
    • 2018-12-25
    相关资源
    最近更新 更多