【发布时间】:2013-10-12 14:44:24
【问题描述】:
我的 rails 应用程序有问题(Rails 4.0.0.rc2,ruby 2.0.0p195)。
行为很奇怪:我的 localhost 正确显示背景图片,Heroku 没有。
在 heroku 日志中,我可以看到以下错误:
ActionController::RoutingError (No route matches [GET] "/assets/piano.jpg"):
我通过在我的 custom.css.scss 中插入以下代码来创建背景图像:
.full {
background: image-url("piano.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
我使用静态页面上的以下代码触发此操作:
<body class="full">
....
</body>
我已经在生产环境中运行 gem:
group :production do
gem 'pg'
gem 'rails_12factor'
end
在 production.rb 中,我将以下设置设置为 true:
config.serve_static_assets = true
但是,图像未显示。你能帮帮我吗?
【问题讨论】:
-
stackoverflow.com/questions/15257555/…你可以参考这个问题。
-
是的。但是,问题不是基于我选择的引用!它与资产的预编译有关。
标签: css ruby-on-rails heroku ruby-on-rails-4 asset-pipeline