简体   繁体   English

在rails应用程序中包含twitter bootstrap

[英]include twitter bootstrap in a rails app

I want to include twitter-bootstrap in one of my rails app. 我想在我的一个Rails应用twitter-bootstrap中包含twitter-bootstrap

I added the gem gem twitter-bootstrap-rails in my Gemfile . 我在Gemfile添加了gem gem twitter-bootstrap-rails And I did the bundle install. 我做了捆绑安装。

But I didn't see the bootstrap's css and js files under the assets of my app. 但是我没有在应用程序的资产下看到引导程序的css和js文件。

Do I need to generate them? 我需要生成它们吗?

Or should I simply download latest bootstrap zip file and add them to my app? 还是我应该只下载最新的bootstrap zip文件并将其添加到我的应用程序中?

So, I want to know what's the best way to include bootstrap in a rails app. 因此,我想知道将引导程序包含在Rails应用程序中的最佳方法是什么。

You need to install bootstrap-sass gem and sass-rails gem. 您需要安装bootstrap-sass gem和sass-rails gem。 after that rename your application.css file to application.scss and add below code 之后,将您的application.css文件重命名为application.scss并添加以下代码

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";

Please check bootstrap gem github page https://github.com/twbs/bootstrap-sass 请检查bootstrap gem github页面https://github.com/twbs/bootstrap-sass

look up the bootstrap-sass gem, its more efficient and practical. 查找自举宝石,它更高效,更实用。 You d definitely want to use it. 您肯定要使用它。

运行捆绑软件安装后,运行引导程序生成器以使用以下命令将Bootstrap包含项添加到资产中:

rails generate bootstrap:install less

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

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