在Gemfile文件中添加'bootstrap-sass',再运行bundle install

gem 'bootstrap-sass'

在config/application.rb添加一行代码,让bootstrap-sass和asset pipeline兼容

  class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
#让bootstrap-sass和asset pipeline兼容
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
end

要使用bootstrap还需要在app/assets/stylesheets目录下创建一个css文件:custom.css.scss

内容为:

@import "bootstrap-sprockets"
@import "bootstrap"

另外在app/assets/javascripts/application.js文件中添加一行

//= require bootstrap

这样才能使用bootstrap的javascript的组件。

现在就可以开始使用bootstrap了。

rails使用bootstrap的更多相关文章

  1. 【转】Rails中Bootstrap的安装和使用

     转自:http://blog.csdn.net/lissdy/article/details/9195651   眼看着前端攻城师们都开始使用Bootstrap创作网页,于是也想学着在最近正在学习的 ...

  2. rails引入bootstrap

    1.在Gemfile中增加 gem 'bootstrap-sass', '~> 3.2.0.2'2.bundle install3.把assets/stylesheets/application ...

  3. 【转】Rails 4中使用 Bootstrap 3

    转自:http://rvg.me/2013/11/using-bootstrap-3-with-rails-4/ If you are looking to use Bootstrap 3 with ...

  4. 在Rails中最方便集成使用Bootstrap的方式

    创建项目 rails new BootstrapProject 创建模型 rails g scaffold xxx --skip-stylesheets 运行迁移 rake db:migrate -- ...

  5. rails bug

    variable @fontAwesomeEotPath_iefix is undefined rails generate bootstrap:install如果还有错,保证在加载主提之前impor ...

  6. rails scaffold生成的crud显示自定义的列名

    1. 访问 rails i18n 插件的官方网站 ,查看信息http://guides.rubyonrails.org/i18n.html2. 在Gemfile 中加入  测试rails4.2.1不用 ...

  7. 软件工程资料 - UCSD 怎么教软件工程

    2012年,在上软件工程课的过程中,收集到这个博客,作为学习资料. 原网站 (http://www.arc-trooper.com)已经不存在,这是一个备份. ----------------- 以下 ...

  8. ror笔记2

    在rails app的 config 文件夹中新建unicorn.rb内容如下 worker_processes 2 working_directory "/home/mage/boleht ...

  9. 推荐一个有趣的Chrome扩展程序-查看任意网站的开发技术栈

    对于前端开发人员来说,目前的前端框架层出不穷,最受欢迎的莫过于所谓的前端框架三驾马车:Angular, React和Vue.在学习的过程中,肯定好奇现在的互联网公司的网站用的何种前端框架来开发的. C ...

随机推荐

  1. jqgrid 分级标题

    参考地址:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:groupingheadar Grouping of the header should ...

  2. python之文件的读写

    读  r   读写模式   r+     如果打开文件时没有指定模式,默认只读,如果使用r或r+,文件不存在时会报错 写  w  写读模式  w+    w模式会清空原有的文件内容 追加 a  追加读 ...

  3. 【Tsinsen】A1280. 最长双回文串

    Bryce1010模板 http://www.tsinsen.com/A1280### 题目分析:记录一个点向后和向前的最长回文串,然后就是max(Llen[i]+Rlen[i+1])了. #incl ...

  4. 牛客国庆集训派对Day_7

    A.Relic Discovery 题目描述 Recently, paleoanthropologists have found historical remains on an island in ...

  5. 区间dp实战练习

    题解报告:poj 2955 Brackets(括号匹配) Description We give the following inductive definition of a “regular br ...

  6. HDU 4366 Successor 分块做法

    http://acm.hdu.edu.cn/showproblem.php?pid=4366 今日重新做了这题的分块,果然是隔太久了,都忘记了.. 首先,用DFS序变成一维的问题 关键是它有两个权值, ...

  7. poj2455Secret Milking Machine(二分+最大流)

    链接 二分距离,小于当前距离的边容量+1,使最后流>=t 注意 会有重边 #include <iostream> #include<cstdio> #include< ...

  8. Java GUI 布局管理器

    容器可设置布局管理器,管理容器中组件的布局: container.setLayout(new XxxLayout()); Java有6种布局管理器,AWT提供了5种: FlowLayout Borde ...

  9. pandas中loc-iloc-ix的使用

    转自:https://www.jianshu.com/p/d6a9845a0a34 Pandas中loc,iloc,ix的使用 使用 iloc 从DataFrame中筛选数据 iloc 是基于“位置” ...

  10. iOS 随笔 允许所有不安全网络访问项目

    允许任意请求访问app   App Transport Security Settings -> Allow Arbitrary Loads  YES