【问题标题】:Rails won't upload css imagesRails 不会上传 CSS 图像
【发布时间】:2013-02-14 20:47:11
【问题描述】:

我已经阅读了其他帖子,但没有一个能解决我的问题。图像已成功上传到 Amazon S3。我已经删除了

config.action_dispatch.x_sendfile_header = "X-Sendfile"

如果我使用,在我的 css 文件中

background-image: url('background.jpg');

图像将在开发模式下显示,但不会在生产模式下显示。

如果我使用

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

图片不会在开发模式或生产模式中显示。我正在使用 rails 3.2.9 谢谢!

【问题讨论】:

  • 尝试:background-image: url(&lt;%= asset_path %&gt;/'background.jpg'),以防您将图像放在资产目录中并且文件以.erb 为前缀。通常url(background.jpg) 就足够了。

标签: ruby-on-rails heroku asset-pipeline


【解决方案1】:

您可能需要配置您的应用以设置其资产主机:config.action_controller.asset_host。本指南可能会对您有所帮助:https://devcenter.heroku.com/articles/cdn-asset-host-rails31

【讨论】:

    猜你喜欢
    • 2012-05-09
    • 1970-01-01
    • 2012-11-09
    • 2016-03-31
    • 1970-01-01
    • 2018-06-24
    • 2013-04-26
    • 2014-11-25
    • 2014-08-18
    相关资源
    最近更新 更多