【问题标题】:Heroku not displaying images or fonts in Rails 4 appHeroku 不在 Rails 4 应用程序中显示图像或字体
【发布时间】:2015-06-02 17:42:00
【问题描述】:

我已经尝试severalguides 让图像和字体出现在 Heroku 上,但似乎没有任何效果。预编译然后推送到 Heroku 和 changing images are referenced 似乎也不起作用。任何帮助将非常感激。 Full source code here.

例如 stylesheets/themes/default/style.css

.iconset {
  background-image: image-url("icon/top-tray.png")  no-repeat;
  background-image: url(image-path('icon/top-tray.png')) no-repeat;
  background-image: asset_path('icon/top-tray.png') no-repeat;
  background: url(<%= asset_path 'icon/top-tray.png' %>) no-repeat;
}

呈现为

.iconset {
  background-image: image-url("icon/top-tray.png")  no-repeat;
  background-image: url(image-path('icon/top-tray.png')) no-repeat;
  background-image: asset_path('icon/top-tray.png') no-repeat;
  background: url(<%= asset_path 'icon/top-tray.png' %>) no-repeat;
}

config/environments/production.rb

  config.serve_static_assets = false
  config.assets.compile = false

config/application.rb

config.assets.paths << Rails.root.join('app', 'assets', 'fonts', 'plugins', 'scss')

config.assets.precompile += %w( .svg .eot .woff .ttf .png .jpg .gif)

【问题讨论】:

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


    【解决方案1】:

    解决方法是将config/environments/production.rb file中的config.assets.compile = false改为config.assets.compile = true

    【讨论】:

    • 不幸的是,这不起作用@cyzanfar。该页面没有完全加载,甚至没有样式表。我已经用更多细节编辑了我的问题,谢谢
    猜你喜欢
    • 2014-02-08
    • 1970-01-01
    • 2016-10-10
    • 2017-05-02
    • 2016-03-19
    • 1970-01-01
    • 2016-03-03
    • 2015-08-04
    • 2016-05-21
    相关资源
    最近更新 更多