Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 部署到Heroku时,Rails中未显示图标_Css_Ruby On Rails_Heroku_Font Awesome - Fatal编程技术网

Css 部署到Heroku时,Rails中未显示图标

Css 部署到Heroku时,Rails中未显示图标,css,ruby-on-rails,heroku,font-awesome,Css,Ruby On Rails,Heroku,Font Awesome,我在许多其他相关的StackOverflow问题中尝试过这些解决方案,但我部署的应用程序仍然显示一个白色的矩形框,而不是图标。在本地主机上运行正常 Gemfile application.css 我已经预编译了资产,并根据以下内容修改了我的application-xxx.css文件: @font-face { font-family: 'FontAwesome'; src: font-url('/assets/fontawesome-webfont.eot'); src: font-

我在许多其他相关的StackOverflow问题中尝试过这些解决方案,但我部署的应用程序仍然显示一个白色的矩形框,而不是图标。在本地主机上运行正常

Gemfile

application.css

我已经预编译了资产,并根据以下内容修改了我的application-xxx.css文件:

@font-face {
  font-family: 'FontAwesome';
  src: font-url('/assets/fontawesome-webfont.eot');
  src: font-url('/assets/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),       font-url('/assets/fontawesome-webfont.woff') format('woff'), font-url('/assets/fontawesome- webfont.ttf') format('truetype'), font-url('/assets/fontawesome- webfont.svg#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}
my production.rb包含

加载应用程序时,控制台上没有错误,但字体未作为资源加载:

有什么问题吗

编辑 问题解决了,恐怕我在运行时没有阅读控制台消息

rake assets:precompile RAILS_ENV=production

我有一些无效的CSS,出于某种原因,在localhost中并不重要,但在生产中却很重要。顺便说一句,我换成了gem字体Aweasome rails。

heroku将css编译成sass,他们提供了一个工具,可以帮助您将css转换成sass

要将gem字体awesomerails放入您的应用程序中,您可以按照中的说明进行操作,记住将css文件包含在application.css中非常重要

祝你一切顺利。希望这能有所帮助

试试看
@font-face {
  font-family: 'FontAwesome';
  src: font-url('/assets/fontawesome-webfont.eot');
  src: font-url('/assets/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),       font-url('/assets/fontawesome-webfont.woff') format('woff'), font-url('/assets/fontawesome- webfont.ttf') format('truetype'), font-url('/assets/fontawesome- webfont.svg#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}
config.serve_static_assets = true
rake assets:precompile RAILS_ENV=production
 /*
 *= require font-awesome
 */