“引导程序"不适用于导轨 3.2.2 [英] the "bootstrap-sass" doesn't work with rails 3.2.2

查看:37
本文介绍了“引导程序"不适用于导轨 3.2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的 rails 项目,并添加

I create a new rails project,and add

gem 'bootstrap-sass'

到我的 Gemfile,然后我运行 bundle install 并且一切顺利.然后我补充:

to my Gemfile, then I run bundle install and every things going good. then I add:

/*
*= require bootstrap
*/

在我的 application.css 文件中,我编写了一个测试,但没有.我也尝试添加`@import "bootstrap";在我的 hello.css.scss 文件中.但它也不起作用.

in my application.css file, and I write a test,but it doesn't. and I also try add`@import "bootstrap"; in my hello.css.scss file .but it also doesn't work.

推荐答案

Rollen,

你似乎大部分时间都在那里.默认情况下,Sass 在 Rails 3.1 中,因此您不需要为此做任何特定的事情.将 gem 添加到 Gemfile 并进行捆绑安装后,您的问题出现在 application.css 文件中.通常,在使用 Sass 时,我只是建议您从 application.css 中删除清单代码(顶部的所有注释)并将 application.css 重命名为 application.css.scss(从 CSS 文件中删除 Sprockets).然后添加:

You seem to be mostly there. Sass is in Rails 3.1 by default so you won't need to do anything specific for that. After you add the gem to your Gemfile and do a bundle install your issue is in the application.css file. Typically when using Sass I'd just suggest that you remove the manifest code (all the commenting at the top) from the application.css and rename the application.css to application.css.scss (removing Sprockets from the CSS file). Then add:

@import 'bootstrap'

到它的最顶端.那应该可以为您解决.您需要手动将要加载的每个 CSS 文件添加到 application.css.scss 文件中,因为链轮已经消失,但这通常是个好主意,因为 CSS 中的加载顺序对于级联很重要.

to the very top of it. That should solve it for you. You'll need to manually add each CSS file you'll want to load into the application.css.scss file since sprockets is gone, but that's typically a good idea anyway since load order in CSS is important for the cascade.

如果您想将 JavaScript 功能添加到框架中(您可能希望这样做),您还需要添加

If you want to add the JavaScript features to the framework (which you likely will want to) you'll also want to add

//= require bootstrap

就在 app/assets/javascripts/application.js 中对 //= require_tree . 的调用上方.

Just above the call to //= require_tree . within app/assets/javascripts/application.js.

这篇关于“引导程序"不适用于导轨 3.2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆