如何在 Ruby on Rails 3.2.12 中使用 Twitter Bootstrap?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15331345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:36:49  来源:igfitidea点击:

How do I use Twitter Bootstrap with Ruby on Rails 3.2.12?

ruby-on-railsruby-on-rails-3twitter-bootstraptwitter-bootstrap-rails

提问by Datsik

I'm switching from PHP to Ruby on Rails and I'm loving it, the only thing is I'm so used to Twitter Bootstrap for most of my designs and now I feel crippled without it, I followed some tutorials like adding bootstrap-sassand what not to my Gemfile, but I still appear to be missing important things like input-block-levelI'm just curious if there is an updated version or a easier tutorial to follow? Thanks.

我正在从 PHP 切换到 Ruby on Rails 并且我很喜欢它,唯一的问题是我已经习惯了 Twitter Bootstrap 用于我的大部分设计,现在我觉得没有它会很瘫痪,我遵循了一些教程,比如添加bootstrap-sass和什么不是我的Gemfile,但我似乎仍然缺少重要的东西,比如input-block-level我只是好奇是否有更新版本或更容易遵循的教程?谢谢。

回答by sameera207

AFAIK, the easiest and most rails way to integrate the twitter bootstrap to rails is via

AFAIK,将 twitter bootstrap 集成到 rails 的最简单和最有效的方法是通过

twitter-bootstrap-railsgem, they have a pretty good documentation too.

twitter-bootstrap-railsgem,他们也有很好的文档。

check these screen casts, and this (premium)to get an idea.

检查这些屏幕投射,以及这个(高级)以获得一个想法。

and welcome to Rails :)

欢迎使用 Rails :)

回答by Mab879

To to the input-block-levelin ERB do something like this

input-block-levelERB 做这样的事情

"input-block-level" => "hello_world"

回答by Benj

Same as you, I'm coming from PHP and love RoR ;)

和你一样,我来自 PHP 并且喜欢 RoR ;)

With bootstrap you need to import it in your manifest. Read a bit about the assets pipeline in RoR guide.

使用引导程序,您需要将其导入清单。在 RoR 指南中阅读一些有关资产管道的信息。

To import bootstrap, create a file in your app/assets/stylesheets directory, with the name you want, but with the extension .css.scss, and place in it the following line:

要导入引导程序,请在您的 app/assets/stylesheets 目录中创建一个文件,使用您想要的名称,但扩展名为 .css.scss,并将以下行放入其中:

@import "bootstrap";

Also if you need to use the javascript helpers from bootstrap, you need to add the following line in your app/assets/javascript/application.js file:

此外,如果您需要使用 bootstrap 中的 javascript 助手,则需要在 app/assets/javascript/application.js 文件中添加以下行:

//= require bootstrap

回答by Rubyist

Just download the bootstrap ( CSS, JS ) file and make the updation in that file at regular interval from his official site : Bootstrap

只需从他的官方网站下载引导程序(CSS,JS)文件并定期更新该文件:Bootstrap

For Bootstrap Tutorials : Click Here

Bootstrap 教程:点击这里

Or you can refer the sample code for reference, because sometimes we dnt get the way to implement such functionality like tooltip.

或者您可以参考示例代码以供参考,因为有时我们无法实现诸如工具提示之类的功能。