css - 另一个 "Foundation icons not display in Heroku Rails 4"帖子

标签 css ruby-on-rails heroku zurb-foundation

我发现有几个线程解决了基础图标在生产环境中不显示但在开发中显示良好的问题。我已遵循其中每个的指示和解决方案,包括尝试 this gem最近使用 this post 没有这个 gem 但我仍然无法在生产中获得图标。

在预编译资源时,字体似乎得到了正确的指纹识别,但 Heroku 似乎找错了地方。以下是 Heroku 日志中的错误之一的示例:

ActionController::RoutingError (No route matches [GET] "/assets/foundation-icons.ttf"):

我尝试过将其添加或不添加到我的 application.css.scss 文件中:

@import 'foundation-icons';

@font-face {
    font-family: "foundation-icons";
    src: font-url( asset-path("foundation-icons.eot") );
    src: font-url( asset-path("foundation-icons.eot?#iefix") )   format("embedded-opentype"),
     font-url( asset-path("foundation-icons.woff") ) format("woff"),
     font-url( asset-path("foundation-icons.ttf") ) format("truetype"),
     font-url( asset-path("foundation-icons.svg#fontcustom") ) format("svg");
  font-weight: normal;
  font-style: normal;
  }

我真的被这个难住了。

最佳答案

当我将包含图标的 css 目录添加到 application.rb 中的 Assets 路径时,我的问题得到了解决:

config.assets.paths << Rails.root.join('app/assets/stylesheets/foundation-icons')

另一种方法是在 application.css 中使用 *= require_directory ./foundation-icons ,假设图标目录位于 app/assets/stylesheets 中

关于css - 另一个 "Foundation icons not display in Heroku Rails 4"帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28464971/

相关文章:

css - 无法在 IE8 中更改链接颜色

html - 应用 onmouseover 更改文本

ruby-on-rails - 列的默认值

ruby-on-rails - has_many 嵌套中的自定义 RESTful 路由

javascript - AngularJS ngAnimate 和 animate.css

jquery - css jquery隐藏一个div,显示另一个

java - ActionCable(Rails5) 和安卓客户端

java - Heroku 和 GIT 的批处理文件不起作用

heroku - 将 Go 应用程序部署到 heroku 错误

java - 使用 Git 将 Java 应用程序部署到 Heroku