我已将 bootstrap 添加到我的网站.这是我正在使用的 struct .(我无法删除bootstrap.css文件,因为我根据自己的喜好修改了它).

>app
>>assets
>>>fonts
>>>>4 glypicons icon files.
>>>images
>>>>N/A
>>>javascripts
>>>>Bootstrap.js (Jquery is installed in a gem)
>>>stylesheets
>>>>Bootstrap.css

所有东西都正确导入了,但问题是这些图标不起作用,我需要它们!

推荐答案

2015年11月编辑:我推荐这款gem:https://github.com/twbs/bootstrap-sass,它由Bootstrap社区积极维护,与Ruby on Rails配合使用效果非常好.

我和你有一个非常相似的问题,但我发现了!在你的 bootstrap 中找到这个部分.css文件:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

/assets代替../fonts/.这就是最终代码的样子.

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('/assets/glyphicons-halflings-regular.eot');
  src: url('/assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('/assets/glyphicons-halflings-regular.woff') format('woff'), url('/assets/glyphicons-halflings-regular.ttf') format('truetype'), url('/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

我希望这有帮助!

Ruby-on-rails相关问答推荐

Rails 7.1解决冲突的Zeitwerk Inflection规则

在Ruby on Rails中获取堆栈级别太深错误(&Q)

将两个日期之间的差值转换为Ruby中的iso8601持续时间(如果需要,还可以使用Rails)

Ruby - 如何删除目录中早于 X 天的所有文件?

Ruby Hash 中 tap / delete 和 except 的区别

如何让删除链接响应 Rails 7 中的 turbo_stream 和 html?

如何验证 Rails 中的多态字段关联?

Ruby 3 动态关键字参数

Rspec期望()与期望{}

使用回形针进行简单裁剪

Rails 4 Form: has_many through: checkboxes

是否有不涉及删除 Gemfile.lock 的在任何源中找不到 *gem*错误的修复?

如何在 ROR (Ruby) 中显示 PDF?

加载常量时自动加载常量时检测到循环依赖

如何在 RSpec 中包含 Rails 助手

Rails Associations - has_many => :through - 但相同的模型

Post.all.map(&:id) 是什么意思?

非持久 ActiveRecord 模型属性

Ruby 中有与 slice 函数相反的函数吗?

Sidekiq Rails 4.2 使用 Active Job 还是 Worker?有什么不同