【问题标题】:Some assets not displaying on Heroku某些资产未在 Heroku 上显示
【发布时间】:2012-07-07 12:15:15
【问题描述】:

我在我的应用程序中添加了一些新图像,它们在本地显示良好,但在 Heroku 上却没有生产。生成的 CSS 引用是正确的:

background-image: url("glyphicons-halflings-white.png")

最终链接到http://www.photoramblr.com/assets/glyphicons-halflings-white.png

那里没有图片,但我过去上传的其他图片都在 /assets/ 下...例如this one。有趣的是,如果我取出一长串数字,只留下原始文件名,图像是空白的......

资产预编译在部署时似乎工作正常,我刚刚尝试在服务器上手动运行资产:预编译,但仍然没有图像。

有什么想法吗?

更新:顺便说一句,看看我的config/application.rb

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  # Bundler.require *Rails.groups(:assets => %w(development test))
  # If you want your assets lazily compiled in production, use this line
  Bundler.require(:default, :assets, Rails.env)
end

module PhotoRambler
  class Application < Rails::Application
    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'

    config.assets.initialize_on_precompile = false
    config.assets.compress = true

【问题讨论】:

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


    【解决方案1】:

    确保将新资产签入源代码管理。

    【讨论】:

    • 他们是。自从提出这个问题后,我也尝试了这个github.com/bokmann/font-awesome-rails,它是一个提供图标的宝石,它们存储在他自己的仓库中;再次在开发中工作正常,但我在生产中一无所获。没有任何意义...
    【解决方案2】:

    奇怪的是,从 Rails 3.1 升级到 Rails 3.2.6 解决了我的问题。不知道为什么。

    【讨论】:

      【解决方案3】:

      我使用的是less/bootstrap,我在CSS中的图片是这样编码的:

      background: image-url("delete.gif") no-repeat ;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-28
        • 1970-01-01
        • 2023-03-25
        • 2019-10-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多