【问题标题】:Heroku Rails 4 assets does not loadHeroku Rails 4 资产不加载
【发布时间】:2018-12-07 20:50:24
【问题描述】:

部署后出现以下错误

这是我的目录

我的应用程序.rb

这里,我怎么称呼他们

<%= stylesheet_link_tag "home" %>
<%= javascript_include_tag "home" %>

<img class="client" src="<%= asset_path('b.png') %>">

OBS:我将 rails 版本从 3.2 升级到 4.0

作为推荐,我从 gemfile 中删除了资产组

gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'

【问题讨论】:

  • 你必须在你的生产配置文件中添加这个配置:config.serve_static_assets = true
  • 同时检查您是否已将 gem rails_12factor 添加到您的 Gemfile 中
  • 是的,我有 gem rails_12factor 和 config.serve_static_assets = true。
  • heroru run rake assets:precompile有效果吗?您能检查一下您的公用文件夹是否已提交吗?
  • 阿尔瓦罗,我解决了。答案如下。感谢您的关注。

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


【解决方案1】:

已解决

错误在scss.erb 文件中。他们没有正确调用像 image_tagasset_path 这样的助手。

在我的应用中有很多 scss.erb 文件,如下所示。

错误

background: url(<%= image_path 'fake_slider.png' %>) no-repeat 0 0;

正确的方式
我将它们放在双引号 " " 中,一切正常。

background: url("<%= image_path 'fake_slider.png' %>") no-repeat 0 0;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 2013-09-13
    • 2015-05-27
    • 2013-09-12
    • 1970-01-01
    相关资源
    最近更新 更多