简体   繁体   English

在Rails 4的ruby中添加bootstrap gem

[英]Adding bootstrap gem to ruby on rails 4

I'm trying to add bootstrap to my ror application. 我正在尝试将引导程序添加到我的ror应用程序中。

I have included this gem 我已经包含了这个宝石

gem 'bootstrap', '~> 4.0.0.beta2.1' gem'bootstrap','〜> 4.0.0.beta2.1'

Bundled Installed this 捆绑安装

Renamed my css file as a .scss 将我的CSS文件重命名为.scss

@import "bootstrap";

And I get this error when I run my project 当我运行项目时出现此错误

Error: File to import not found or unreadable: bootstrap. 错误:找不到导入文件或不可读:引导程序。 on line 1 of /home/ubuntu/workspace/shc-pms/app/assets/stylesheets/application.scss 在/home/ubuntu/workspace/shc-pms/app/assets/stylesheets/application.scss的第1行上

1: @import "bootstrap"; 1:@import“引导程序”;

Note: If you use bootstrap-sprockets (@import "bootstrap-sprockets";) , you will get the error: 注意:如果使用bootstrap-sprockets (@import "bootstrap-sprockets";) ,则会出现错误:

File to import not found or unreadable: bootstrap-sprockets 找不到要导入的文件或不可读的文件:引导链轮

Gemfile 宝石文件

gem 'bootstrap', '~> 4.0.0'

Ensure that sprockets-rails is at least v2.3.2 . 确保sprockets-rails至少为v2.3.2

Remove: 去掉:

*= require_tree .
*= require_self

from application.scss . 来自application.scss Use @import to import sass file. 使用@import导入sass文件。 Add: 加:

@import "bootstrap";

to application.js. 到application.js。 It will now look like this: 现在看起来像这样:

//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require_tree .

Restart the server, see what's happening. 重新启动服务器,看看发生了什么事。

I fixed it by deleteing everything from css/scss files. 我通过删除css / scss文件中的所有内容来修复它。 Deleting scss file. 删除scss文件。 Using the gem - gem 'bootstrap', and linking the cdn to my application.html.erb file 使用gem-gem'bootstrap',并将CDN链接到我的application.html.erb文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM