在 Rails 应用程序上安装 Bootstrap 3 [英] Installing Bootstrap 3 on Rails App

查看:53
本文介绍了在 Rails 应用程序上安装 Bootstrap 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Rails 应用上安装 Bootstrap 3.0.我最近完成了 Michael Hartl 的教程,现在正在尝试使用这个新版本的 Bootstrap 构建我自己的系统,但我有一些我不确定的问题.

I'm trying to install Bootstrap 3.0 on my Rails app. I recently finished Michael Hartl's tutorial and am now trying to build my own system using this new version of Bootstrap, but I have a few questions that I'm not sure about.

我的系统规格:

  • 基于 MBP 的 OS X Mountain Lion
  • Rails 4.0
  • Ruby 2.0

我的问题:

  1. 在我的 Gemfile 中使用的最佳 gem 是什么?我找到了一些.
  2. 我要在 custom.css.scss 上导入什么?我在某处读到它与 2.3.2 不同.
  3. 我还需要做些什么才能使 Bootstrap 正常工作,或者其余步骤与我在 Bootstrap 2.3.2 中遵循的步骤相同吗?
  1. What is the best gem to use in my Gemfile? I have found a few of them.
  2. What do I import on my custom.css.scss? I read somewhere that it's different from 2.3.2.
  3. Is there anything else I have to do to get Bootstrap to work, or are the remaining steps identical to the ones I followed for Bootstrap 2.3.2?

编辑

以下是 GitHub 上的 bootstrap-rails 项目 首先说明要执行的操作:

Here is what the bootstrap-rails project on GitHub first says to do:

gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
                              :github => 'anjlab/bootstrap-rails'

然后它说要做:

gem 'anjlab-bootstrap-rails', '>= 3.0.0.0', :require => 'bootstrap-rails'

他们做同样的事情,还是你必须同时做?

Do they do the same thing, or do you have to do them both?

推荐答案

其实你不需要gem,这里是在RoR中安装Bootstrap 3的步骤

Actually you don't need gem for this, here is the step to install Bootstrap 3 in RoR

复制:

bootstrap-dist/css/bootstrap.cssbootstrap-dist/css/bootstrap.min.css

收件人:vendor/assets/stylesheets

复制:

bootstrap-dist/js/bootstrap.jsbootstrap-dist/js/bootstrap.min.js

收件人:vendor/assets/javascripts

更新: app/assets/stylesheets/application.css 通过添加:

*= require bootstrap.min

  • 更新: app/assets/javascripts/application.js通过添加:

    //= require bootstrap.min
    

  • 有了这个,您可以随时更新引导程序,无需等待 gem 更新.同样采用这种方法,资产管道将在生产中使用缩小版本.

    With this you can update bootstrap any time you want, don't need to wait gem to be updated. Also with this approach assets pipeline will use minified versions in production.

    这篇关于在 Rails 应用程序上安装 Bootstrap 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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